This differential uses JSI introduced in parent differential to update unread count for each keyserver from JS on native.
Details
Build iOS app and send notifications and/or update unread status on web client on both backgrounded and foregrounded app. Ensure unread count
functionality is not broken.
Diff Detail
- Repository
- rCOMM Comm
- Branch
- marcin/eng-6501
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
native/push/push-handler.react.js | ||
---|---|---|
111 | I was thinking about this and I reached a conclusion that we don't need to check whether we are connected to a keyserver. The reason for that is that when we receive notification it triggers redux update so that extendedUnreadCount selector is recalculated. This means that if we are disconnected from the keyserver then redux either reflects the state from the last time we were connected to the keyserver or we received a notif containing never state that triggered redux update. In either case we should the value from redux to calculate total unread count. |
lib/ops/keyserver-store-ops.js | ||
---|---|---|
136–145 | Nit: weird that you're mixing paradigms here... why not replace your for loop with a filter, so it matches with the map / flat approach later? | |
native/push/push-handler.react.js | ||
111 | I'm not sure I follow this reasoning. The behavior before was that the unread count could be updated in one of two ways:
I'm concerned that the user might open the app and have the badge count immediately update based on the app's out-of-date local data, which would be bad because it may be more out-of-date than the prior badge count (based on a notif). |
lib/ops/keyserver-store-ops.js | ||
---|---|---|
136–145 | I opted for this since in the following construction: const removeKeyserversOperations = ops.filter(op => op.type === 'remove_keyservers') flow doesn't understand that the array now consists of RemoveKeyserversOperation only but thinks that this array can contain any KeyserverStoreOperation. This breaks map used later. In order to use filter exclusively we need sth like this: return ops .filter(op => op.type === 'remove_keyservers') .map(operation => operation.payload?.ids) .filter(Boolean) .flat(); Fot me personally it is even weirder since we are checking for values that we are sure that are truthy. |
lib/selectors/keyserver-selectors.js | ||
---|---|---|
111 ↗ | (On Diff #37884) | This is just KeyserverInfos |
native/push/push-handler.react.js | ||
623 ↗ | (On Diff #37884) | Shouldn't this be messages for keyserverID? i.e. keyserverIDToMessageInfos[keyserverID] |
742–744 ↗ | (On Diff #37884) | extractKeyserverIDFromID returns a string, it's not possible for this to be falsy unless it's an empty string, which would mean that message.threadID was an empty string. I don't think this is possible? |
lib/selectors/thread-selectors.js | ||
---|---|---|
293 ↗ | (On Diff #37884) | We already have allUpdatesCurrentAsOff selector in this file that returns similar thing. I will update to allUnreadCounts to match convention. |
native/push/push-handler.react.js | ||
623 ↗ | (On Diff #37884) | Definitely - my mistake. |
742–744 ↗ | (On Diff #37884) | According to @inka explanation invariant seems to be best choice here. |
- Address JS nits
- Distapch saveMessagesActionType action with message for one keyserver (fixing bug indentified by inka)
lib/ops/keyserver-store-ops.js | ||
---|---|---|
133–145 ↗ | (On Diff #37937) | In this case, we could consider making both transformations in the for loop instead. Also, I think that having a flat array isn't ideal, because it won't handle duplicated IDs properly. |
lib/selectors/keyserver-selectors.js | ||
111–117 ↗ | (On Diff #37937) | This could be expressed using lodash |
native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java | ||
52–53 ↗ | (On Diff #37937) | Can we define a separate constant for a separator and avoid including the separator in prefixes and suffixes? |
235–242 ↗ | (On Diff #37937) | We can consider simplifying this logic |
247 ↗ | (On Diff #37937) | What does -1 mean? |
- Address JS nits.
- Separate mmkv prefixes and suffixes from separator.
- Use constants for mmkv key handling on iOS in the NSE code.
LGTM, although I am not familiar with our Objective-C/java code
native/ios/NotificationService/NotificationService.mm | ||
---|---|---|
17–19 ↗ | (On Diff #37965) | Do these values have to be in sync with values form CommNotificationsHandler.java? If so, should we write comment? |
476–481 ↗ | (On Diff #37965) | Can't we do the same simplification as in here? |
native/push/push-handler.react.js | ||
742–744 ↗ | (On Diff #37884) | My point was actually that keyserverID should always be a non-empty string, so even the invariant is unnecessary |
- Remove invariant.
- Add comments for devs to make sure that constants in CommNotificationsHandler.java match constants in NotificationService.mm.
- Simplify total unread count calculation logic in NotificationService.mm.