Created
August 21, 2024 16:46
-
-
Save marcinwasowicz/e0e48311f76df2acbacd0ac59e888a9c to your computer and use it in GitHub Desktop.
ChangeThreadSubscription test plan.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/web/chat/chat-input-bar.react.js b/web/chat/chat-input-bar.react.js | |
index 03ca0c4e44..52fb742053 100644 | |
--- a/web/chat/chat-input-bar.react.js | |
+++ b/web/chat/chat-input-bar.react.js | |
@@ -64,6 +64,13 @@ import { | |
webMentionTypeaheadRegex, | |
} from '../utils/typeahead-utils.js'; | |
+import { type DMOperation } from 'lib/types/dm-ops.js'; | |
+import type { MessageSourceMetadata } from 'lib/types/db-ops-types.js'; | |
+import uuid from 'uuid'; | |
+import { useProcessDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; | |
+import type { DMOperationSpecification } from 'lib/shared/dm-ops/dm-op-utils.js'; | |
+import { usePeerToPeerCommunication } from 'lib/tunnelbroker/peer-to-peer-context.js'; | |
+ | |
type BaseProps = { | |
+threadInfo: ThreadInfo, | |
+inputState: InputState, | |
@@ -83,6 +90,11 @@ type Props = { | |
+currentUserIsVoiced: boolean, | |
+currentUserCanJoinThread: boolean, | |
+threadFrozen: boolean, | |
+ +processDMOperation: ( | |
+ dmOp: DMOperation, | |
+ metadata: ?MessageSourceMetadata, | |
+ ) => Promise<void>, | |
+ +sendDMOperation: (dmOp: DMOperationSpecification) => Promise<void>, | |
}; | |
class ChatInputBar extends React.PureComponent<Props> { | |
@@ -502,6 +514,42 @@ class ChatInputBar extends React.PureComponent<Props> { | |
this.props.threadInfo, | |
this.props.parentThreadInfo, | |
); | |
+ | |
+ void (async () => { | |
+ const viewerID = this.props.viewerID; | |
+ invariant(viewerID, 'should have viewer ID in order to send a message'); | |
+ const tid = uuid.v4(); | |
+ const createThreadOperation = { | |
+ type: 'create_thread', | |
+ threadID: tid, | |
+ creatorID: viewerID, | |
+ time: Date.now(), | |
+ threadType: 13, | |
+ memberIDs: ['17A07D8F-DCFB-479D-998B-25C8F86B44B3'], | |
+ roleID: uuid.v4(), | |
+ newMessageID: uuid.v4(), | |
+ }; | |
+ await this.props.processDMOperation(createThreadOperation); | |
+ await this.props.sendDMOperation({ | |
+ op: createThreadOperation, | |
+ supportsAutoRetry: false, | |
+ recipients: { type: 'all_peer_devices' }, | |
+ }); | |
+ | |
+ const changeSubscriptionOperation = { | |
+ type: 'change_thread_subscription', | |
+ creatorID: viewerID, | |
+ time: Date.now(), | |
+ threadID: tid, | |
+ subscription: { home: false, pushNotifs: false }, | |
+ }; | |
+ await this.props.processDMOperation(changeSubscriptionOperation); | |
+ await this.props.sendDMOperation({ | |
+ op: changeSubscriptionOperation, | |
+ supportsAutoRetry: false, | |
+ recipients: { type: 'all_peer_devices' }, | |
+ }); | |
+ })(); | |
} | |
multimediaInputRef = (multimediaInput: ?HTMLInputElement) => { | |
@@ -667,7 +715,8 @@ const ConnectedChatInputBar: React.ComponentType<BaseProps> = | |
() => [...suggestedUsers, ...suggestedChats], | |
[suggestedUsers, suggestedChats], | |
); | |
- | |
+ const processDMOperation = useProcessDMOperation(); | |
+ const { sendDMOperation } = usePeerToPeerCommunication(); | |
return ( | |
<ChatInputBar | |
{...props} | |
@@ -684,6 +733,8 @@ const ConnectedChatInputBar: React.ComponentType<BaseProps> = | |
currentUserIsVoiced={currentUserIsVoiced} | |
currentUserCanJoinThread={currentUserCanJoinThread} | |
threadFrozen={threadFrozen} | |
+ processDMOperation={processDMOperation} | |
+ sendDMOperation={sendDMOperation} | |
/> | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment