Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3181903
D12713.id42219.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
D12713.id42219.diff
View Options
diff --git a/lib/shared/community-utils.js b/lib/shared/community-utils.js
--- a/lib/shared/community-utils.js
+++ b/lib/shared/community-utils.js
@@ -29,6 +29,7 @@
import type { SetState } from '../types/hook-types.js';
import { defaultKeyserverInfo } from '../types/keyserver-types.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
+import type { ThreadSubscription } from '../types/subscription-types.js';
import { threadPermissions } from '../types/thread-permission-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
import { useCurrentUserFID } from '../utils/farcaster-utils.js';
@@ -185,9 +186,10 @@
+setOngoingJoinData: SetState<?OngoingJoinCommunityData>,
+step: JoinCommunityStep,
+setStep: SetState<JoinCommunityStep>,
- +inviteSecret: string,
- +setLinkStatus: SetState<LinkStatus>,
+ +inviteSecret?: string,
+ +setLinkStatus?: SetState<LinkStatus>,
+threadID?: string,
+ +defaultSubscription?: ThreadSubscription,
};
function useJoinCommunity(params: UseJoinCommunityParams): () => Promise<void> {
const {
@@ -201,6 +203,7 @@
inviteSecret,
setLinkStatus,
threadID,
+ defaultSubscription,
} = params;
const dispatch = useDispatch();
@@ -238,7 +241,7 @@
keyserverID !== extractKeyserverIDFromID(communityID)
) {
reject();
- setLinkStatus('invalid');
+ setLinkStatus?.('invalid');
setOngoingJoinData(null);
return;
}
@@ -246,7 +249,7 @@
reject();
setOngoingJoinData(oldData => {
if (oldData) {
- setLinkStatus('timed_out');
+ setLinkStatus?.('timed_out');
}
return null;
});
@@ -289,7 +292,7 @@
const isValid = await isKeyserverURLValid();
if (!isValid || !keyserverURL) {
- setLinkStatus('invalid');
+ setLinkStatus?.('invalid');
ongoingJoinData.reject();
setOngoingJoinData(null);
return;
@@ -339,6 +342,7 @@
],
},
inviteLinkSecret: inviteSecret,
+ defaultSubscription,
});
void dispatchActionPromise(joinThreadActionTypes, joinThreadPromise);
@@ -346,7 +350,9 @@
await joinThreadPromise;
setStep('join_thread');
} catch (e) {
- setLinkStatus(status => (status === 'valid' ? 'invalid' : status));
+ setLinkStatus?.((status: LinkStatus) =>
+ status === 'valid' ? 'invalid' : status,
+ );
ongoingJoinData.reject();
setOngoingJoinData(null);
}
@@ -354,6 +360,7 @@
}, [
calendarQuery,
callJoinThread,
+ defaultSubscription,
dispatchActionPromise,
inviteSecret,
ongoingJoinData,
@@ -395,7 +402,9 @@
setStep('finished');
ongoingJoinData.resolve();
} catch (e) {
- setLinkStatus(status => (status === 'valid' ? 'invalid' : status));
+ setLinkStatus?.((status: LinkStatus) =>
+ status === 'valid' ? 'invalid' : status,
+ );
ongoingJoinData.reject();
} finally {
setOngoingJoinData(null);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 7:13 AM (20 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2449969
Default Alt Text
D12713.id42219.diff (3 KB)
Attached To
Mode
D12713: [lib] make useJoinCommunity compatible with the auto join community handler
Attached
Detach File
Event Timeline
Log In to Comment