Page MenuHomePhabricator

D4508.id14411.diff
No OneTemporary

D4508.id14411.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
@@ -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

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)

Event Timeline