Skip to content

Commit

Permalink
[lib] fix PushHandler to support DMs
Browse files Browse the repository at this point in the history
Summary: Solution described in [ENG-9465](https://linear.app/comm/issue/ENG-9465/messages-from-thick-thread-notifs-dont-seem-to-be-integrated-into#comment-685bf427).

Test Plan:
Apply this diff:
1. Comment [this](https://github.com/CommE2E/comm/blob/cfc5daf4fbc477221cbd541241e6d9a6fc0774ca/lib/tunnelbroker/peer-to-peer-message-handler.js#L142) line to make sure we're testing actual notifs code & add some logs to make sure code in reducer was executed.
2. Open physical device
3. In DM thread send a test message
4. Notif delivered
5. Message immediately visible in UI
6. Thread marked as unread
5. Logs from reducer are there

Reviewers: ashoat, kamil

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D13576
  • Loading branch information
xsanm authored and palys-swm committed Oct 2, 2024
1 parent 642f52d commit d304b0b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
32 changes: 31 additions & 1 deletion lib/reducers/thread-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,38 @@ function reduceThreadInfos(
const changedThreadInfos: { [string]: RawThreadInfo } = {};
for (const [threadID, mostRecentTime] of threadIDToMostRecentTime) {
const threadInfo = state.threadInfos[threadID];
if (!threadInfo) {
continue;
}

if (threadInfo.thick) {
if (threadInfo.timestamps.currentUser.unread > mostRecentTime) {
continue;
}
changedThreadInfos[threadID] = {
...threadInfo,
timestamps: {
...threadInfo.timestamps,
currentUser: {
...threadInfo.timestamps.currentUser,
unread: mostRecentTime,
},
},
};
if (!threadInfo.currentUser.unread) {
changedThreadInfos[threadID] = {
...changedThreadInfos[threadID],
currentUser: {
...threadInfo.currentUser,
unread: true,
},
};
}
continue;
}

if (
!threadInfo ||
!action.payload.updatesCurrentAsOf ||
threadInfo.currentUser.unread ||
action.payload.updatesCurrentAsOf > mostRecentTime
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/types/message-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ export type GenericMessagesResult = {

export type SaveMessagesPayload = {
+rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,
+updatesCurrentAsOf: number,
+updatesCurrentAsOf: ?number,
};

export type NewMessagesPayload = {
Expand Down
3 changes: 0 additions & 3 deletions native/push/push-handler.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,6 @@ class PushHandler extends React.PureComponent<Props, State> {
for (const keyserverID in keyserverIDToMessageInfos) {
const updatesCurrentAsOf = this.props.allUpdatesCurrentAsOf[keyserverID];
const messageInfos = keyserverIDToMessageInfos[keyserverID];
if (!updatesCurrentAsOf) {
continue;
}

this.props.dispatch({
type: saveMessagesActionType,
Expand Down

0 comments on commit d304b0b

Please sign in to comment.