Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32375285
D9369.1765328026.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D9369.1765328026.diff
View Options
diff --git a/lib/actions/message-report-actions.js b/lib/actions/message-report-actions.js
--- a/lib/actions/message-report-actions.js
+++ b/lib/actions/message-report-actions.js
@@ -4,7 +4,9 @@
MessageReportCreationRequest,
MessageReportCreationResult,
} from '../types/message-report-types.js';
-import type { CallServerEndpoint } from '../utils/call-server-endpoint.js';
+import { extractKeyserverIDFromID } from '../utils/action-utils.js';
+import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js';
+import { useKeyserverCall } from '../utils/keyserver-call.js';
const sendMessageReportActionTypes = Object.freeze({
started: 'SEND_MESSAGE_REPORT_STARTED',
@@ -13,12 +15,25 @@
});
const sendMessageReport =
(
- callServerEndpoint: CallServerEndpoint,
+ callKeyserverEndpoint: CallKeyserverEndpoint,
): ((
- request: MessageReportCreationRequest,
+ input: MessageReportCreationRequest,
) => Promise<MessageReportCreationResult>) =>
- async request => {
- return await callServerEndpoint('create_message_report', request);
+ async input => {
+ const keyserverID = extractKeyserverIDFromID(input.messageID);
+ const requests = { [keyserverID]: input };
+
+ const response = (
+ await callKeyserverEndpoint('create_message_report', requests)
+ )[keyserverID];
+
+ return { messageInfo: response.messageInfo };
};
-export { sendMessageReportActionTypes, sendMessageReport };
+function useSendMessageReport(): (
+ input: MessageReportCreationRequest,
+) => Promise<MessageReportCreationResult> {
+ return useKeyserverCall(sendMessageReport);
+}
+
+export { sendMessageReportActionTypes, useSendMessageReport };
diff --git a/native/chat/message-report-utils.js b/native/chat/message-report-utils.js
--- a/native/chat/message-report-utils.js
+++ b/native/chat/message-report-utils.js
@@ -3,13 +3,10 @@
import * as React from 'react';
import {
- sendMessageReport,
+ useSendMessageReport,
sendMessageReportActionTypes,
} from 'lib/actions/message-report-actions.js';
-import {
- useServerCall,
- useDispatchActionPromise,
-} from 'lib/utils/action-utils.js';
+import { useDispatchActionPromise } from 'lib/utils/action-utils.js';
import { displayActionResultModal } from '../navigation/action-result-modal.js';
import type { TooltipRoute } from '../tooltip/tooltip.react.js';
@@ -24,7 +21,7 @@
): () => mixed {
const messageID = route.params.item.messageInfo.id;
const dispatchActionPromise = useDispatchActionPromise();
- const callSendMessageReport = useServerCall(sendMessageReport);
+ const callSendMessageReport = useSendMessageReport();
return React.useCallback(() => {
if (!messageID) {
Alert.alert(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 12:53 AM (18 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5859417
Default Alt Text
D9369.1765328026.diff (2 KB)
Attached To
Mode
D9369: [lib][web][native] Refactor actions in message-report-actions.js
Attached
Detach File
Event Timeline
Log In to Comment