Page MenuHomePhabricator

D4508.id14456.diff
No OneTemporary

D4508.id14456.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);
+ }
+ }
+
+ messageStore = {
+ ...messageStore,
+ messages: actionPayloadMessages,
+ threads: newThreads,
+ local: newLocal,
+ };
+
+ 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, Nov 24, 12:20 PM (21 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575540
Default Alt Text
D4508.id14456.diff (2 KB)

Event Timeline