Stage 11: account linking & merge (email + Telegram Login Widget) (#12)
This commit was merged in pull request #12.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// gateway calls funnel through here so errors map to one user-facing toast and an
|
||||
// expired session logs out.
|
||||
|
||||
import type { Profile, PushEvent, Session } from './model';
|
||||
import type { LinkResult, Profile, PushEvent, Session } from './model';
|
||||
import { gateway } from './gateway';
|
||||
import { GatewayError } from './client';
|
||||
import { navigate, router } from './router.svelte';
|
||||
@@ -129,6 +129,19 @@ async function adoptSession(s: Session): Promise<void> {
|
||||
void refreshNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* applyLinkResult applies a completed account link or merge (Stage 11): it adopts a
|
||||
* switched session (a guest initiator whose durable counterpart won, so the active
|
||||
* account changed) or, otherwise, refreshes the current profile in place.
|
||||
*/
|
||||
export async function applyLinkResult(r: LinkResult): Promise<void> {
|
||||
if (r.session && r.session.token) {
|
||||
await adoptSession(r.session);
|
||||
return;
|
||||
}
|
||||
app.profile = await gateway.profileGet();
|
||||
}
|
||||
|
||||
export async function bootstrap(): Promise<void> {
|
||||
const prefs = await loadPrefs();
|
||||
app.theme = prefs.theme ?? 'auto';
|
||||
|
||||
Reference in New Issue
Block a user