diff --git a/lib/shared/updates/join-thread-spec.js b/lib/shared/updates/join-thread-spec.js --- a/lib/shared/updates/join-thread-spec.js +++ b/lib/shared/updates/join-thread-spec.js @@ -178,4 +178,7 @@ truncationStatus: messageTruncationStatusValidator, rawEntryInfos: t.list(rawEntryInfoValidator), }), + getUpdatedThreadInfo(update: ThreadJoinUpdateInfo) { + return update.threadInfo; + }, }); diff --git a/lib/shared/updates/update-spec.js b/lib/shared/updates/update-spec.js --- a/lib/shared/updates/update-spec.js +++ b/lib/shared/updates/update-spec.js @@ -14,9 +14,11 @@ MessageTruncationStatuses, FetchMessageInfosResult, } from '../../types/message-types.js'; +import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js'; import type { RawThreadInfos, MixedRawThreadInfos, + LegacyRawThreadInfo, } from '../../types/thread-types.js'; import type { UpdateType } from '../../types/update-types-enum.js'; import type { @@ -103,4 +105,8 @@ +generateOpsForUserInfoUpdates?: ( update: UpdateInfo, ) => ?$ReadOnlyArray, + +getUpdatedThreadInfo?: ( + update: UpdateInfo, + threadInfo: LegacyRawThreadInfo | RawThreadInfo, + ) => LegacyRawThreadInfo | RawThreadInfo, }; diff --git a/lib/shared/updates/update-thread-read-status-spec.js b/lib/shared/updates/update-thread-read-status-spec.js --- a/lib/shared/updates/update-thread-read-status-spec.js +++ b/lib/shared/updates/update-thread-read-status-spec.js @@ -3,7 +3,11 @@ import t from 'tcomb'; import type { UpdateSpec } from './update-spec.js'; -import type { RawThreadInfos } from '../../types/thread-types.js'; +import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js'; +import type { + LegacyRawThreadInfo, + RawThreadInfos, +} from '../../types/thread-types.js'; import { updateTypes } from '../../types/update-types-enum.js'; import type { ThreadReadStatusUpdateInfo, @@ -106,4 +110,25 @@ threadID: tID, unread: t.Boolean, }), + getUpdatedThreadInfo( + update: ThreadReadStatusUpdateInfo, + threadInfo: LegacyRawThreadInfo | RawThreadInfo, + ): LegacyRawThreadInfo | RawThreadInfo { + if (threadInfo.minimallyEncoded) { + return { + ...threadInfo, + currentUser: { + ...threadInfo.currentUser, + unread: update.unread, + }, + }; + } + return { + ...threadInfo, + currentUser: { + ...threadInfo.currentUser, + unread: update.unread, + }, + }; + }, }); diff --git a/lib/shared/updates/update-thread-spec.js b/lib/shared/updates/update-thread-spec.js --- a/lib/shared/updates/update-thread-spec.js +++ b/lib/shared/updates/update-thread-spec.js @@ -119,4 +119,7 @@ time: t.Number, threadInfo: mixedRawThreadInfoValidator, }), + getUpdatedThreadInfo(update: ThreadUpdateInfo) { + return update.threadInfo; + }, });