diff --git a/lib/utils/thread-ops-utils.js b/lib/utils/thread-ops-utils.js index f753b2950..39b46585d 100644 --- a/lib/utils/thread-ops-utils.js +++ b/lib/utils/thread-ops-utils.js @@ -1,62 +1,64 @@ // @flow import { assertThreadType } from '../types/thread-types-enum.js'; import { type ClientDBThreadInfo, type LegacyRawThreadInfo, + type RawThreadInfo, } from '../types/thread-types.js'; function convertRawThreadInfoToClientDBThreadInfo( - rawThreadInfo: LegacyRawThreadInfo, + rawThreadInfo: RawThreadInfo, ): ClientDBThreadInfo { + const { minimallyEncoded, ...rest } = rawThreadInfo; return { - ...rawThreadInfo, + ...rest, creationTime: rawThreadInfo.creationTime.toString(), members: JSON.stringify(rawThreadInfo.members), roles: JSON.stringify(rawThreadInfo.roles), currentUser: JSON.stringify(rawThreadInfo.currentUser), avatar: rawThreadInfo.avatar ? JSON.stringify(rawThreadInfo.avatar) : null, }; } function convertClientDBThreadInfoToRawThreadInfo( clientDBThreadInfo: ClientDBThreadInfo, ): LegacyRawThreadInfo { let rawThreadInfo: LegacyRawThreadInfo = { id: clientDBThreadInfo.id, type: assertThreadType(clientDBThreadInfo.type), name: clientDBThreadInfo.name, description: clientDBThreadInfo.description, color: clientDBThreadInfo.color, creationTime: Number(clientDBThreadInfo.creationTime), parentThreadID: clientDBThreadInfo.parentThreadID, containingThreadID: clientDBThreadInfo.containingThreadID, community: clientDBThreadInfo.community, members: JSON.parse(clientDBThreadInfo.members), roles: JSON.parse(clientDBThreadInfo.roles), currentUser: JSON.parse(clientDBThreadInfo.currentUser), repliesCount: clientDBThreadInfo.repliesCount, pinnedCount: clientDBThreadInfo.pinnedCount, }; if (clientDBThreadInfo.sourceMessageID) { rawThreadInfo = { ...rawThreadInfo, sourceMessageID: clientDBThreadInfo.sourceMessageID, }; } if (clientDBThreadInfo.avatar) { rawThreadInfo = { ...rawThreadInfo, avatar: JSON.parse(clientDBThreadInfo.avatar), }; } return rawThreadInfo; } export { convertRawThreadInfoToClientDBThreadInfo, convertClientDBThreadInfoToRawThreadInfo, };