Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3354200
D4508.id14456.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.id14456.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);
+ }
+ }
+
+ 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
Details
Attached
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)
Attached To
Mode
D4508: Filter local multimedia messages
Attached
Detach File
Event Timeline
Log In to Comment