Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509683
D9372.id31687.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9372.id31687.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 7:20 AM (5 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690550
Default Alt Text
D9372.id31687.diff (3 KB)
Attached To
Mode
D9372: [lib] Handle `send*MessageActionTypes.started` in `reduceThreadActivity`
Attached
Detach File
Event Timeline
Log In to Comment