Page MenuHomePhabricator

D9372.id31687.diff
No OneTemporary

D9372.id31687.diff

diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -149,6 +149,7 @@
threadActivityStore: reduceThreadActivity(
state.threadActivityStore,
action,
+ threadInfos,
),
},
storeOperations: {
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -1806,4 +1806,8 @@
};
}
-export { freshMessageStore, reduceMessageStore };
+export {
+ freshMessageStore,
+ reduceMessageStore,
+ ensureRealizedThreadIDIsUsedWhenPossible,
+};
diff --git a/lib/reducers/thread-activity-reducer.js b/lib/reducers/thread-activity-reducer.js
--- a/lib/reducers/thread-activity-reducer.js
+++ b/lib/reducers/thread-activity-reducer.js
@@ -1,5 +1,11 @@
// @flow
+import { ensureRealizedThreadIDIsUsedWhenPossible } from './message-reducer.js';
+import {
+ sendMultimediaMessageActionTypes,
+ sendReactionMessageActionTypes,
+ sendTextMessageActionTypes,
+} from '../actions/message-actions.js';
import {
logOutActionTypes,
deleteAccountActionTypes,
@@ -7,11 +13,13 @@
import type { BaseAction } from '../types/redux-types.js';
import type { ThreadActivityStore } from '../types/thread-activity-types.js';
import { updateThreadLastNavigatedActionType } from '../types/thread-activity-types.js';
+import type { RawThreadInfo } from '../types/thread-types.js';
import { setNewSessionActionType } from '../utils/action-utils.js';
function reduceThreadActivity(
state: ThreadActivityStore,
action: BaseAction,
+ newThreadInfos: { +[id: string]: RawThreadInfo },
): ThreadActivityStore {
if (action.type === updateThreadLastNavigatedActionType) {
const { threadID, time } = action.payload;
@@ -23,6 +31,25 @@
},
};
return updatedThreadActivityStore;
+ } else if (
+ action.type === sendTextMessageActionTypes.started ||
+ action.type === sendMultimediaMessageActionTypes.started ||
+ action.type === sendReactionMessageActionTypes.started
+ ) {
+ const payload = ensureRealizedThreadIDIsUsedWhenPossible(
+ action.payload,
+ newThreadInfos,
+ );
+ const { threadID } = payload;
+ const now = Date.now();
+
+ return {
+ ...state,
+ [threadID]: {
+ lastNavigatedTo: state[threadID]?.lastNavigatedTo ?? now,
+ lastPruned: state[threadID]?.lastPruned ?? now,
+ },
+ };
} else if (
action.type === logOutActionTypes.success ||
action.type === deleteAccountActionTypes.success ||
diff --git a/lib/reducers/thread-activity-reducer.test.js b/lib/reducers/thread-activity-reducer.test.js
--- a/lib/reducers/thread-activity-reducer.test.js
+++ b/lib/reducers/thread-activity-reducer.test.js
@@ -34,7 +34,7 @@
lastPruned: 1639522314170,
},
};
- const result = reduceThreadActivity(initialState, action);
+ const result = reduceThreadActivity(initialState, action, {});
expect(result).toEqual(expectedState);
});
@@ -63,7 +63,7 @@
lastPruned: 1639522314170,
},
};
- const result = reduceThreadActivity(initialState, action);
+ const result = reduceThreadActivity(initialState, action, {});
expect(result).toEqual(expectedState);
});
});

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 7:20 AM (52 m, 18 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690550
Default Alt Text
D9372.id31687.diff (3 KB)

Event Timeline