diff --git a/lib/shared/unshim-utils.js b/lib/shared/unshim-utils.js index 4b3752893..ab45faf1f 100644 --- a/lib/shared/unshim-utils.js +++ b/lib/shared/unshim-utils.js @@ -1,55 +1,56 @@ // @flow import _mapValues from 'lodash/fp/mapValues'; import { type MessageStore, type RawMessageInfo, type MessageType, messageTypes, } from '../types/message-types'; import { messageSpecs } from './messages/message-specs'; function unshimFunc( messageInfo: RawMessageInfo, unshimTypes: Set, ): RawMessageInfo { if (messageInfo.type !== messageTypes.UNSUPPORTED) { return messageInfo; } if (!unshimTypes.has(messageInfo.unsupportedMessageInfo.type)) { return messageInfo; } const unwrapped = messageInfo.unsupportedMessageInfo; const { unshimMessageInfo } = messageSpecs[unwrapped.type]; const unshimmed = unshimMessageInfo?.(unwrapped, messageInfo); return unshimmed ?? unwrapped; } function unshimMessageStore( messageStore: MessageStore, unshimTypes: $ReadOnlyArray, ): MessageStore { const set = new Set(unshimTypes); const messages = _mapValues((messageInfo: RawMessageInfo) => unshimFunc(messageInfo, set), )(messageStore.messages); return { ...messageStore, messages }; } const localUnshimTypes = new Set([ messageTypes.IMAGES, messageTypes.UPDATE_RELATIONSHIP, messageTypes.CREATE_SIDEBAR, messageTypes.SIDEBAR_SOURCE, messageTypes.MULTIMEDIA, + messageTypes.REACTION, ]); function unshimMessageInfos( messageInfos: $ReadOnlyArray, ): RawMessageInfo[] { return messageInfos.map((messageInfo: RawMessageInfo) => unshimFunc(messageInfo, localUnshimTypes), ); } export { unshimMessageStore, unshimMessageInfos, unshimFunc };