-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not use view context in StreamChat #3550
Conversation
let context = viewContext | ||
let context = backgroundReadOnlyContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mistake in PR:3541
Generated by 🚫 Danger |
@MainActor public func makeConnectedUser() throws -> ConnectedUser { | ||
let user = try CurrentUserDTO.load(context: databaseContainer.viewContext) | ||
public func makeConnectedUser() throws -> ConnectedUser { | ||
let user = try databaseContainer.readAndWait { session in | ||
guard let dto = session.currentUser else { throw ClientError.CurrentUserDoesNotExist() } | ||
return try dto.asModel() | ||
} | ||
return ConnectedUser(user: user, client: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All our other make methods do not require @MainActor
, therefore we should skip it here as well. Downside is that this change would generate a warning that no await is needed if it was called outside of MainActor. Can we make this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's fine
SDK Size
|
SDK Performance
|
SDK Size
|
@MainActor public func makeConnectedUser() throws -> ConnectedUser { | ||
let user = try CurrentUserDTO.load(context: databaseContainer.viewContext) | ||
public func makeConnectedUser() throws -> ConnectedUser { | ||
let user = try databaseContainer.readAndWait { session in | ||
guard let dto = session.currentUser else { throw ClientError.CurrentUserDoesNotExist() } | ||
return try dto.asModel() | ||
} | ||
return ConnectedUser(user: user, client: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's fine
Quality Gate passedIssues Measures |
🔗 Issue Links
🎯 Goal
Do not use
viewContext
in LLC📝 Summary
🛠 Implementation
We should use background context for reading and
writableContext
for writing. There is not need forviewContext
anymore. Remove viewContext references from LLC (except DataContainer). Many of our tests still accessviewContext
.🎨 Showcase
🧪 Manual Testing Notes
N/A
☑️ Contributor Checklist
docs-content
repo