Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3361072
D12425.id41282.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
D12425.id41282.diff
View Options
diff --git a/lib/hooks/invite-links.js b/lib/hooks/invite-links.js
--- a/lib/hooks/invite-links.js
+++ b/lib/hooks/invite-links.js
@@ -199,6 +199,7 @@
+resolve: () => mixed,
+reject: () => mixed,
+communityID: string,
+ +threadID: ?string,
}>(null);
const timeoutRef = React.useRef<?TimeoutID>();
@@ -214,6 +215,7 @@
| 'add_keyserver'
| 'auth_to_keyserver'
| 'join_community'
+ | 'join_thread'
| 'finished',
>('inactive');
@@ -251,10 +253,16 @@
resolve: resolveAndClearTimeout,
reject: rejectAndClearTimeout,
communityID,
+ threadID: verificationResponse.thread?.id,
});
setStep('add_keyserver');
});
- }, [communityID, keyserverID, setLinkStatus]);
+ }, [
+ communityID,
+ keyserverID,
+ setLinkStatus,
+ verificationResponse.thread?.id,
+ ]);
React.useEffect(() => {
void (async () => {
@@ -320,6 +328,53 @@
});
void dispatchActionPromise(joinThreadActionTypes, joinThreadPromise);
+ try {
+ await joinThreadPromise;
+ setStep('join_thread');
+ } catch (e) {
+ setLinkStatus(status => (status === 'valid' ? 'invalid' : status));
+ ongoingJoinData.reject();
+ setOngoingJoinData(null);
+ }
+ })();
+ }, [
+ calendarQuery,
+ callJoinThread,
+ dispatchActionPromise,
+ inviteSecret,
+ ongoingJoinData,
+ setLinkStatus,
+ step,
+ ]);
+
+ React.useEffect(() => {
+ void (async () => {
+ if (!ongoingJoinData || step !== 'join_thread') {
+ return;
+ }
+ const threadID = ongoingJoinData.threadID;
+ if (!threadID) {
+ setStep('finished');
+ ongoingJoinData.resolve();
+ setOngoingJoinData(null);
+ return;
+ }
+
+ const query = calendarQuery();
+ const joinThreadPromise = callJoinThread({
+ threadID,
+ calendarQuery: {
+ startDate: query.startDate,
+ endDate: query.endDate,
+ filters: [
+ ...query.filters,
+ { type: 'threads', threadIDs: [threadID] },
+ ],
+ },
+ inviteLinkSecret: inviteSecret,
+ });
+ void dispatchActionPromise(joinThreadActionTypes, joinThreadPromise);
+
try {
await joinThreadPromise;
setStep('finished');
@@ -346,18 +401,24 @@
if (step !== 'finished') {
return;
}
- const threadID = verificationResponse.community?.id;
- if (!threadID || !threadInfos[threadID]) {
+ const joinedThreadID = verificationResponse.thread?.id;
+ if (joinedThreadID && threadInfos[joinedThreadID]) {
+ navigateToThread(threadInfos[joinedThreadID]);
+ return;
+ }
+ const joinedCommunityID = verificationResponse.community?.id;
+ if (!joinedCommunityID || !threadInfos[joinedCommunityID]) {
closeModal();
return;
}
- navigateToThread(threadInfos[threadID]);
+ navigateToThread(threadInfos[joinedCommunityID]);
}, [
closeModal,
navigateToThread,
step,
threadInfos,
verificationResponse.community?.id,
+ verificationResponse.thread?.id,
]);
let joinLoadingStatus: LoadingStatus = 'inactive';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 3:10 PM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579857
Default Alt Text
D12425.id41282.diff (3 KB)
Attached To
Mode
D12425: [lib] Join a thread from an invite link
Attached
Detach File
Event Timeline
Log In to Comment