Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3392101
D4508.id14411.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4508.id14411.diff
View Options
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
@@ -1287,13 +1287,69 @@
},
};
} else if (action.type === setMessageStoreMessages) {
+ // When starting the app on native, we filter out any local-only multimedia
+ // messages because the relevant context is no longer available
+ const { threads, local } = messageStore;
+ let newThreads = threads;
+ let newLocal = local;
+
+ const actionPayloadMessages = translateClientDBMessageInfosToRawMessageInfos(
+ action.payload,
+ );
+ const messageIDsToBeRemoved = [];
+
+ for (const id in actionPayloadMessages) {
+ const message = actionPayloadMessages[id];
+ if (
+ (message.type === messageTypes.IMAGES ||
+ message.type === messageTypes.MULTIMEDIA) &&
+ !message.id
+ ) {
+ const { threadID } = message;
+ messageIDsToBeRemoved.push(id);
+ newThreads = {
+ ...newThreads,
+ [threadID]: {
+ ...newThreads[threadID],
+ messageIDs: newThreads[threadID].messageIDs.filter(
+ curMessageID => curMessageID !== id,
+ ),
+ },
+ };
+ newLocal = _pickBy(
+ (localInfo: LocalMessageInfo, key: string) => key !== id,
+ )(newLocal);
+ }
+ }
+
+ const updatedMessageStore = {
+ ...messageStore,
+ messages: { ...messageStore.messages, ...actionPayloadMessages },
+ };
+
+ if (newThreads === threads) {
+ return { messageStoreOperations: [], messageStore: updatedMessageStore };
+ }
+
+ const messageStoreOperations: MessageStoreOperation[] = [
+ {
+ type: 'remove',
+ payload: { ids: messageIDsToBeRemoved },
+ },
+ ];
+
+ const processedMessageStore = processMessageStoreOperations(
+ updatedMessageStore,
+ messageStoreOperations,
+ );
+
return {
- messageStoreOperations: [],
+ messageStoreOperations,
messageStore: {
...messageStore,
- messages: translateClientDBMessageInfosToRawMessageInfos(
- action.payload,
- ),
+ messages: processedMessageStore.messages,
+ threads: newThreads,
+ local: newLocal,
},
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 6:58 AM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2604124
Default Alt Text
D4508.id14411.diff (2 KB)
Attached To
Mode
D4508: Filter local multimedia messages
Attached
Detach File
Event Timeline
Log In to Comment