diff --git a/lib/actions/activity-actions.js b/lib/actions/activity-actions.js --- a/lib/actions/activity-actions.js +++ b/lib/actions/activity-actions.js @@ -22,6 +22,7 @@ } from '../types/activity-types.js'; import type { DMChangeThreadReadStatusOperation } from '../types/dm-ops.js'; import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types'; +import { threadTypeIsThick } from '../types/thread-types-enum.js'; import { useSelector } from '../utils/redux-utils.js'; export type UpdateActivityInput = { @@ -109,19 +110,12 @@ }; }; -export type UseSetThreadUnreadStatusInput = $ReadOnly< - | { - +thick: false, - ...SetThreadUnreadStatusRequest, - } - | { - +thick: true, - +threadInfo: ThreadInfo, - ...SetThreadUnreadStatusRequest, - }, ->; +export type UseSetThreadUnreadStatusInput = { + +threadInfo: ThreadInfo, + ...SetThreadUnreadStatusRequest, +}; function useSetThreadUnreadStatus(): ( - imput: UseSetThreadUnreadStatusInput, + input: UseSetThreadUnreadStatusInput, ) => Promise { const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, @@ -131,8 +125,8 @@ return React.useCallback( async (input: UseSetThreadUnreadStatusInput) => { - if (!input.thick) { - const { thick, ...rest } = input; + if (!threadTypeIsThick(input.threadInfo.type)) { + const { threadInfo, ...rest } = input; return await keyserverCall({ ...rest }); } diff --git a/lib/hooks/toggle-unread-status.js b/lib/hooks/toggle-unread-status.js --- a/lib/hooks/toggle-unread-status.js +++ b/lib/hooks/toggle-unread-status.js @@ -9,7 +9,6 @@ import type { UseSetThreadUnreadStatusInput } from '../actions/activity-actions.js'; import type { SetThreadUnreadStatusPayload } from '../types/activity-types.js'; import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; -import { threadTypeIsThick } from '../types/thread-types-enum.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; function useToggleUnreadStatus( @@ -24,18 +23,12 @@ ) => Promise = useSetThreadUnreadStatus(); const toggleUnreadStatus = React.useCallback(() => { - const request = { + const input = { + threadInfo, threadID: threadInfo.id, unread: !currentUser.unread, latestMessage: mostRecentNonLocalMessage, }; - const input = threadTypeIsThick(threadInfo.type) - ? { - thick: true, - threadInfo, - ...request, - } - : { thick: false, ...request }; void dispatchActionPromise( setThreadUnreadStatusActionTypes,