Skip to content

Commit

Permalink
[lib] Handle messageStorePruneActionType in reduceThreadActivity
Browse files Browse the repository at this point in the history
Summary:
We want to upsert `lastPruned` for `threadIDs` included in `messageStorePruneActionType` payload in `threadActivityStore`.

---

Depends on D9404

Test Plan:
1. Modify pruning code to run every minute
2. Observe that `lastPruned` inside `threadActivityStore` gets set as expected on `messageStorePruneActionType`

Reviewers: ashoat, ginsu, tomek

Reviewed By: ashoat

Subscribers: wyilio

Differential Revision: https://phab.comm.dev/D9406
  • Loading branch information
atulsmadhugiri committed Oct 9, 2023
1 parent 8a192aa commit 37ed3d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/reducers/thread-activity-reducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow

import { messageStorePruneActionType } from '../actions/message-actions.js';
import {
deleteThreadActionTypes,
leaveThreadActionTypes,
Expand Down Expand Up @@ -29,6 +30,19 @@ function reduceThreadActivity(
},
};
return updatedThreadActivityStore;
} else if (action.type === messageStorePruneActionType) {
const now = Date.now();
let updatedThreadActivityStore = { ...state };
for (const threadID: string of action.payload.threadIDs) {
updatedThreadActivityStore = {
...updatedThreadActivityStore,
[threadID]: {
...updatedThreadActivityStore[threadID],
lastPruned: now,
},
};
}
return updatedThreadActivityStore;
} else if (
action.type === leaveThreadActionTypes.success ||
action.type === deleteThreadActionTypes.success
Expand Down

0 comments on commit 37ed3d6

Please sign in to comment.