@@ -33,8 +33,18 @@ export type CommunityOnboardingTransaction = {
3333 createdAt : string ;
3434 updatedAt : string ;
3535 error ?: string ;
36+ // Deep links are persisted before machine onboarding completes. Set when
37+ // the user dismisses the acknowledgment so it stays dismissed on relaunch.
38+ acknowledged ?: boolean ;
3639} ;
3740
41+ export type CommunityOnboardingTransactionPatch = Partial <
42+ Pick <
43+ CommunityOnboardingTransaction ,
44+ "stage" | "communityId" | "communityName" | "error" | "acknowledged"
45+ >
46+ > ;
47+
3848export type StartCommunityOnboardingInput = {
3949 source : CommunityOnboardingSource ;
4050 relayUrl : string ;
@@ -119,6 +129,9 @@ export function startCommunityOnboarding(
119129 reposDir : input . reposDir ?? existing . reposDir ,
120130 updatedAt : now . toISOString ( ) ,
121131 error : undefined ,
132+ // A freshly opened link deserves fresh feedback — re-present the gate
133+ // even if a previous link for this relay was already dismissed.
134+ acknowledged : undefined ,
122135 } ;
123136 saveCommunityOnboardingTransaction ( updated , storage ) ;
124137 return updated ;
@@ -143,12 +156,7 @@ export function startCommunityOnboarding(
143156
144157export function updateCommunityOnboardingTransaction (
145158 transaction : CommunityOnboardingTransaction ,
146- patch : Partial <
147- Pick <
148- CommunityOnboardingTransaction ,
149- "stage" | "communityId" | "communityName" | "error"
150- >
151- > ,
159+ patch : CommunityOnboardingTransactionPatch ,
152160 storage : Storage = localStorage ,
153161 now = new Date ( ) ,
154162) : CommunityOnboardingTransaction {
@@ -157,6 +165,17 @@ export function updateCommunityOnboardingTransaction(
157165 return updated ;
158166}
159167
168+ export function updateCurrentCommunityOnboardingTransaction (
169+ current : CommunityOnboardingTransaction | null ,
170+ patch : CommunityOnboardingTransactionPatch ,
171+ expectedId : string | undefined ,
172+ storage : Storage = localStorage ,
173+ now = new Date ( ) ,
174+ ) : CommunityOnboardingTransaction | null {
175+ if ( ! current || ( expectedId && current . id !== expectedId ) ) return current ;
176+ return updateCommunityOnboardingTransaction ( current , patch , storage , now ) ;
177+ }
178+
160179export function markCommunityOnboardingComplete (
161180 pubkey : string ,
162181 relayUrl : string ,
@@ -177,12 +196,8 @@ type CommunityOnboardingContextValue = {
177196 transaction : CommunityOnboardingTransaction | null ;
178197 start : ( input : StartCommunityOnboardingInput ) => boolean ;
179198 update : (
180- patch : Partial <
181- Pick <
182- CommunityOnboardingTransaction ,
183- "stage" | "communityId" | "communityName" | "error"
184- >
185- > ,
199+ patch : CommunityOnboardingTransactionPatch ,
200+ expectedId ?: string ,
186201 ) => void ;
187202 clear : ( ) => void ;
188203} ;
@@ -212,18 +227,9 @@ export function CommunityOnboardingProvider({
212227 [ transaction ] ,
213228 ) ;
214229 const update = React . useCallback (
215- (
216- patch : Partial <
217- Pick <
218- CommunityOnboardingTransaction ,
219- "stage" | "communityId" | "communityName" | "error"
220- >
221- > ,
222- ) => {
230+ ( patch : CommunityOnboardingTransactionPatch , expectedId ?: string ) => {
223231 setTransaction ( ( current ) =>
224- current
225- ? updateCommunityOnboardingTransaction ( current , patch )
226- : current ,
232+ updateCurrentCommunityOnboardingTransaction ( current , patch , expectedId ) ,
227233 ) ;
228234 } ,
229235 [ ] ,
0 commit comments