Page MenuHomePhabricator

D4508.id14736.diff
No OneTemporary

D4508.id14736.diff

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
@@ -1285,13 +1285,68 @@
},
};
} 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
+ let threads = { ...messageStore.threads };
+ let local = { ...messageStore.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);
+ threads = {
+ ...threads,
+ [threadID]: {
+ ...threads[threadID],
+ messageIDs: threads[threadID].messageIDs.filter(
+ curMessageID => curMessageID !== id,
+ ),
+ },
+ };
+ local = _pickBy(
+ (localInfo: LocalMessageInfo, key: string) => key !== id,
+ )(local);
+ }
+ }
+
+ messageStore = {
+ ...messageStore,
+ messages: actionPayloadMessages,
+ threads: threads,
+ local: local,
+ };
+
+ if (messageIDsToBeRemoved.length === 0) {
+ return { messageStoreOperations: [], messageStore };
+ }
+
+ const messageStoreOperations: MessageStoreOperation[] = [
+ {
+ type: 'remove',
+ payload: { ids: messageIDsToBeRemoved },
+ },
+ ];
+
+ const processedMessageStore = processMessageStoreOperations(
+ messageStore,
+ messageStoreOperations,
+ );
+
return {
- messageStoreOperations: [],
+ messageStoreOperations,
messageStore: {
...messageStore,
- messages: translateClientDBMessageInfosToRawMessageInfos(
- action.payload,
- ),
+ messages: processedMessageStore.messages,
},
};
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 6:43 AM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2602146
Default Alt Text
D4508.id14736.diff (2 KB)

Event Timeline