From 097977552fcfe4f279aaa2cbd5228e0e92f8e1b1 Mon Sep 17 00:00:00 2001 From: xsanm Date: Tue, 27 Aug 2024 20:44:54 +0200 Subject: [PATCH] [lib] update `creatorID` -> `unread` in `CreateThickRawThreadInfoInput` Summary: [ENG-8568](https://linear.app/comm/issue/ENG-8568/logic-for-adding-a-user-user-joining-a-thick-thread) We need to use `CreateThickRawThreadInfoInput` when creating `ADD_VIEWER_TO_THREAD_MEMBERS`, where it's complicated to retrieve `creatorID`. `creatorID` is used only for computing `unread`, that being said we can simplify this. Test Plan: Flow Reviewers: tomek, inka Reviewed By: tomek Subscribers: ashoat Differential Revision: https://phab.comm.dev/D13181 --- lib/shared/dm-ops/create-sidebar-spec.js | 2 +- lib/shared/dm-ops/create-thread-spec.js | 6 +++--- lib/types/dm-ops.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/shared/dm-ops/create-sidebar-spec.js b/lib/shared/dm-ops/create-sidebar-spec.js index eb1852d567..f9714d70d6 100644 --- a/lib/shared/dm-ops/create-sidebar-spec.js +++ b/lib/shared/dm-ops/create-sidebar-spec.js @@ -116,7 +116,7 @@ const createSidebarSpec: DMOperationSpec = parentThreadID, allMemberIDs, roleID, - creatorID, + unread: creatorID !== viewerID, sourceMessageID, containingThreadID: parentThreadID, }, diff --git a/lib/shared/dm-ops/create-thread-spec.js b/lib/shared/dm-ops/create-thread-spec.js index 208607eaac..7723e5da59 100644 --- a/lib/shared/dm-ops/create-thread-spec.js +++ b/lib/shared/dm-ops/create-thread-spec.js @@ -67,7 +67,7 @@ function createThickRawThreadInfo( parentThreadID, allMemberIDs, roleID, - creatorID, + unread, name, avatar, description, @@ -107,7 +107,7 @@ function createThickRawThreadInfo( role: role.id, permissions: membershipPermissions, subscription: joinThreadSubscription, - unread: creatorID !== viewerID, + unread, }), repliesCount: repliesCount ?? 0, name, @@ -171,7 +171,7 @@ const createThreadSpec: DMOperationSpec = creationTime: time, allMemberIDs, roleID, - creatorID, + unread: creatorID !== viewerID, }, viewerID, ); diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js index 54d362a73f..c7015e343c 100644 --- a/lib/types/dm-ops.js +++ b/lib/types/dm-ops.js @@ -40,7 +40,7 @@ export type CreateThickRawThreadInfoInput = { +parentThreadID?: ?string, +allMemberIDs: $ReadOnlyArray, +roleID: string, - +creatorID: string, + +unread: boolean, +name?: ?string, +avatar?: ?ClientAvatar, +description?: ?string, @@ -58,7 +58,7 @@ export const createThickRawThreadInfoInputValidator: TInterface