Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370698
D13303.id44101.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13303.id44101.diff
View Options
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
@@ -20,7 +20,6 @@
} 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 = {
@@ -108,10 +107,19 @@
};
};
-function useSetThreadUnreadStatus(
- threadInfo: ThreadInfo,
-): (
- request: SetThreadUnreadStatusRequest,
+export type UseSetThreadUnreadStatusInput = $ReadOnly<
+ | {
+ +thick: false,
+ ...SetThreadUnreadStatusRequest,
+ }
+ | {
+ +thick: true,
+ +threadInfo: ThreadInfo,
+ ...SetThreadUnreadStatusRequest,
+ },
+>;
+function useSetThreadUnreadStatus(): (
+ imput: UseSetThreadUnreadStatusInput,
) => Promise<SetThreadUnreadStatusPayload> {
const viewerID = useSelector(
state => state.currentUserInfo && state.currentUserInfo.id,
@@ -120,12 +128,14 @@
const keyserverCall = useKeyserverCall(setThreadUnreadStatus);
return React.useCallback(
- async (input: SetThreadUnreadStatusRequest) => {
- if (!threadTypeIsThick(threadInfo.type)) {
- return await keyserverCall(input);
+ async (input: UseSetThreadUnreadStatusInput) => {
+ if (!input.thick) {
+ const { thick, ...rest } = input;
+ return await keyserverCall({ ...rest });
}
invariant(viewerID, 'viewerID must be set');
+ const { threadInfo } = input;
const op: DMChangeThreadReadStatusOperation = {
type: 'change_thread_read_status',
time: Date.now(),
@@ -149,7 +159,7 @@
};
},
- [keyserverCall, threadInfo, viewerID, processAndSendDMOperation],
+ [keyserverCall, viewerID, processAndSendDMOperation],
);
}
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
@@ -6,11 +6,10 @@
setThreadUnreadStatusActionTypes,
useSetThreadUnreadStatus,
} from '../actions/activity-actions.js';
-import type {
- SetThreadUnreadStatusPayload,
- SetThreadUnreadStatusRequest,
-} from '../types/activity-types.js';
+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(
@@ -21,9 +20,8 @@
const dispatchActionPromise = useDispatchActionPromise();
const { currentUser } = threadInfo;
const boundSetThreadUnreadStatus: (
- request: SetThreadUnreadStatusRequest,
- ) => Promise<SetThreadUnreadStatusPayload> =
- useSetThreadUnreadStatus(threadInfo);
+ input: UseSetThreadUnreadStatusInput,
+ ) => Promise<SetThreadUnreadStatusPayload> = useSetThreadUnreadStatus();
const toggleUnreadStatus = React.useCallback(() => {
const request = {
@@ -31,9 +29,17 @@
unread: !currentUser.unread,
latestMessage: mostRecentNonLocalMessage,
};
+ const input = threadTypeIsThick(threadInfo.type)
+ ? {
+ thick: true,
+ threadInfo,
+ ...request,
+ }
+ : { thick: false, ...request };
+
void dispatchActionPromise(
setThreadUnreadStatusActionTypes,
- boundSetThreadUnreadStatus(request),
+ boundSetThreadUnreadStatus(input),
undefined,
({
threadID: threadInfo.id,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 3:48 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587311
Default Alt Text
D13303.id44101.diff (3 KB)
Attached To
Mode
D13303: Update input type of useSetThreadUnreadStatus
Attached
Detach File
Event Timeline
Log In to Comment