Skip to content
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

refactor: integrate new incremental sync - WPB-15440 #2579

Draft
wants to merge 70 commits into
base: develop
Choose a base branch
from

Conversation

johnxnguyen
Copy link
Collaborator

@johnxnguyen johnxnguyen commented Feb 21, 2025

TaskWPB-15440 [iOS] Integrate quick sync with in the app

Issue

Please describe the issue.

Optional: add details about technical approach, solutions etc.

Optional: reference dependencies to other pull requests etc.

Testing

Describe how to test.

Optional: attachments like images, videos, etc.


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Github is getting confused by a deleted file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encoding and decoding between UpdateEventEnvelope and Data moved inside the local store.

Comment on lines +65 to +70
/// Delete the event envelope with the given index.
/// - parameter index: The index of the envelope to delete

func deleteEventEnvelope(
atIndex index: Int64
) async throws
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this so we can store and delete live events (events that come through the push channel one by one)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted because it's dead and no longer needed.

do {
if let incrementalSyncTask {
WireLogger.sync.info("incremental sync already running, waiting for it instead")
try await incrementalSyncTask.value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: interesting, when does the task is set to nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I forgot to clear it after.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 532b5d8

Comment on lines 54 to 55
logger.debug("pulling pending events")
try await updateEventsSync.pull()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: this is just a fetch /notifications here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't have expected we fetch nor process the events before opening the channel, but I might forget something here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fetches events from backend, decrypts, and stores them in the event database. The sequence is:

  1. Open push channel, but buffer events (don't even decrypt them)
  2. Fetch, decrypt, and store events in the DB
  3. Fetch and process events from the DB
  4. Decrypt and process buffered events from push channel
  5. Decrypt and process new events from push channel

try await processStoredEvents()

return Task { @Sendable [logger, decryptor, store, processor] in
let jsonEncoder = JSONEncoder()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: shouldn't we wrapped in a do catch here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think much about how we handle errors in event processing at the moment because we have another ticket for that. I suppose here we want to handle errors differently, for example:

  • Decryption errors: log and ignore?
  • Processing errors: keep in DB, log and continue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants