-
Notifications
You must be signed in to change notification settings - Fork 24
fix: invisible groups - WPB-20123 #3792
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
base: release/cycle-4.10
Are you sure you want to change the base?
Conversation
d95d9ff to
3b5f27c
Compare
WireDomain/Sources/WireDomain/WorkAgent/Worker/SyncConversationsWorker.swift
Outdated
Show resolved
Hide resolved
| public func start() async { | ||
| fetchedResultsController.delegate = self | ||
| do { | ||
| try fetchedResultsController.performFetch() |
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 class monitors the coredata change, and create ticket for scheduler
| var epoch: Int64 = 0 | ||
| if let context, let conversation = fetchConversationInfo( | ||
| with: groupID, | ||
| in: context | ||
| )?.conversation { | ||
| epoch = Int64(conversation.epoch) |
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 part getting the epoch outside the CoreData context was failing on debug build
| func performIncrementalSync() async throws { | ||
|
|
||
| Task { | ||
| await conversationsMonitor.start() |
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.
we start generating the conversation sync with backend tickets only after initial sync is finished, in order to avoid having conversations syncing twice (in Worker and in InitialSync)
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.
suggestion: if the monitor is inside the worker, we could instead tell the workers to "start" and "stop" work. In this case, the conversation worker would start and stop monitoring. We could even add these start stop methods as optional protocol methods on Worker, then flip a flag on the work agent isAcceptingTickets or isOpen, which would then inform all its workers to start or stop. What do you think?
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.
so workers would start when WorkAgent start to run, right?
in the case of conversations, I don't know if that would solve the issue where initialSync pulling conversations would create conversations with needsToBeUpdatedFromBackend = true and trigger the worker.
- Did you mean that we should move setting needsToBeUpdatedFromBackend to true or false within the Worker?
| }() | ||
|
|
||
| extension InitiateResetMLSConversationUseCase: ResetBrokenMLSConversationDelegate { | ||
| public lazy var conversationMonitor: ConversationUpdatesGeneratorProtocol = ConversationUpdatesGenerator( |
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.
suggestion: if we say that the worker is responsible for keeping local conversations in sync with the backend, then I would expect the worker to be capable of monitoring the database and raising tickets autonomously. In which case, the worker retains the monitor, the monitor simply informs a delegate or via callback that there are objects that it detected, and the worker creates the ticket.
| func performIncrementalSync() async throws { | ||
|
|
||
| Task { | ||
| await conversationsMonitor.start() |
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.
suggestion: if the monitor is inside the worker, we could instead tell the workers to "start" and "stop" work. In this case, the conversation worker would start and stop monitoring. We could even add these start stop methods as optional protocol methods on Worker, then flip a flag on the work agent isAcceptingTickets or isOpen, which would then inform all its workers to start or stop. What do you think?
89e0cdf to
87a55b8
Compare
5361b25 to
99138f9
Compare
| /// Cancel the work item. | ||
|
|
||
| func cancel() async | ||
| // func cancel() async |
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.
@johnxnguyen this is not implemented, I wonder if we keep it
Test Results 21 files 1 225 suites 12m 57s ⏱️ For more details on these failures, see this check. Results for commit 2524cb0. ♻️ This comment has been updated with latest results. |
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.
Looks good. I've just left a few comments
| self.conversationID = conversationID | ||
| } | ||
|
|
||
| func start() async throws { |
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.
question (out of scope): @netbe @johnxnguyen Am I right that the way a WorkAgent has changed since we discussed it last Friday? The work now belongs to a WorkItem and not some other actor?
There were a few things that were nice about the old approach:
- Less need to pass dependencies to the place that the work item is created.
- Possibility to persist work item across app runs.
Anyway this is out of scope for this PR.
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 basically what change
| var id = UUID() | ||
| var priority: WorkItemPriority { | ||
| .medium | ||
| } | ||
|
|
||
| var conversationID: WireNetwork.QualifiedID |
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.
question: Why are id and conversationID publicly mutable?
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.
no reason, true I'll make it a let
| for type: NSFetchedResultsChangeType, | ||
| newIndexPath: IndexPath? | ||
| ) { | ||
| guard let conversation = anObject as? ZMConversation else { return } |
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.
suggestion: Crash if this fails. The fetched results controller is configured in this file so we know that anObject right?
Issue
Sometimes conversations are not shown within the app. Some conversations were found not updated with data from backend for example having a invalid groupType hence not displayed.
Right now, the ConversationsRequestStrategy with the updateSync (KeyPathObjectSync) sync the conversation with the backend when the
NeedsToBeUpdatedFromBackendproperty is set to true, but it does not wait for the request to finish to turn off the flag, so if the request fails or the app crashes, we'll never retry the request.Solution:
ConversationUpdatesGeneratorcreatesUpdateConversationItemworkItems for the WorkAgent.Other changes:
Testing
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: