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: process conversation access update event - WPB-10164 #2028

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jullianm
Copy link
Contributor

@jullianm jullianm commented Oct 14, 2024

WPB-10164

Key points

This PR is part of the quick sync refactoring plan and is related to processing the multiple events we receive from the backend or the push channel.

Specifically, this PR is about porting the existing implementation of the ConversationAccessUpdate event.

Testing

UTs cover the following use cases, ensuring that:

  • conversation is properly fetched locally
  • conversation roles and modes are properly updated locally
  • conversation roles are properly updated based on legacy role

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.

@echoes-hq echoes-hq bot added echoes: maintenance Maintenance activity - Refactoring , Preventive , Improvements to code , Performance improvements echoes/initiative: ios-sync-refactoring labels Oct 14, 2024
@jullianm jullianm requested a review from netbe October 14, 2024 13:48
Copy link
Contributor

github-actions bot commented Oct 14, 2024

Test Results

2 669 tests   2 669 ✅  8m 38s ⏱️
  298 suites      0 💤
    3 files        0 ❌

Results for commit 8f5048f.

♻️ This comment has been updated with latest results.


await context.perform {
localConversation.accessModeStrings = event.accessModes.map(\.rawValue)
localConversation.accessRoleStringsV2 = accessRoles.map(\.rawValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

context.save() ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think saves should happen on a higher level. For instance:

  • Get batch of pending events
  • Process batch of events (no saves in-between)
  • After successfully processing all events in batch, one single save, then delete those pending events (they are consumed now

We need to take care that any committed work isn't repeated in case of any interruption to the event processing.

Comment on lines +53 to +55
await context.perform {
localConversation.accessModeStrings = event.accessModes.map(\.rawValue)
localConversation.accessRoleStringsV2 = accessRoles.map(\.rawValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be part of the repository?


await context.perform {
localConversation.accessModeStrings = event.accessModes.map(\.rawValue)
localConversation.accessRoleStringsV2 = accessRoles.map(\.rawValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think saves should happen on a higher level. For instance:

  • Get batch of pending events
  • Process batch of events (no saves in-between)
  • After successfully processing all events in batch, one single save, then delete those pending events (they are consumed now

We need to take care that any committed work isn't repeated in case of any interruption to the event processing.

domain: conversationID.domain
)

let accessRoles = if let legacyAccessRole = event.legacyAccessRole {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm... do we even need to handle the legacy roles anymore? The newer roles are always present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes/initiative: ios-sync-refactoring echoes: maintenance Maintenance activity - Refactoring , Preventive , Improvements to code , Performance improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants