diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -302,7 +302,7 @@ +id: string, +type: number, +name: ?string, - +avatar?: ?ClientAvatar, + +avatar?: ?string, +description: ?string, +color: string, +creationTime: string, diff --git a/lib/utils/thread-ops-utils.js b/lib/utils/thread-ops-utils.js --- a/lib/utils/thread-ops-utils.js +++ b/lib/utils/thread-ops-utils.js @@ -17,26 +17,43 @@ 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, ): RawThreadInfo { - const { sourceMessageID, ...rawThreadInfo }: RawThreadInfo = { - ...clientDBThreadInfo, + let rawThreadInfo: RawThreadInfo = { + 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, }; + if (clientDBThreadInfo.sourceMessageID) { - return { + rawThreadInfo = { ...rawThreadInfo, sourceMessageID: clientDBThreadInfo.sourceMessageID, }; } + + if (clientDBThreadInfo.avatar) { + rawThreadInfo = { + ...rawThreadInfo, + avatar: JSON.parse(clientDBThreadInfo.avatar), + }; + } + return rawThreadInfo; }