From 37ed3d6636fece9effd0007750b5f374261cdb82 Mon Sep 17 00:00:00 2001 From: Atul Madhugiri Date: Fri, 6 Oct 2023 16:18:59 -0400 Subject: [PATCH] [lib] Handle `messageStorePruneActionType` in `reduceThreadActivity` 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 --- lib/reducers/thread-activity-reducer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/reducers/thread-activity-reducer.js b/lib/reducers/thread-activity-reducer.js index 255c87313e..092ee8e817 100644 --- a/lib/reducers/thread-activity-reducer.js +++ b/lib/reducers/thread-activity-reducer.js @@ -1,5 +1,6 @@ // @flow +import { messageStorePruneActionType } from '../actions/message-actions.js'; import { deleteThreadActionTypes, leaveThreadActionTypes, @@ -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