diff --git a/src/app/components/SpaceInviteAccept.svelte b/src/app/components/SpaceInviteAccept.svelte index 2e2f0125..02a9dcf4 100644 --- a/src/app/components/SpaceInviteAccept.svelte +++ b/src/app/components/SpaceInviteAccept.svelte @@ -23,6 +23,7 @@ import SpaceJoinStatus from "@app/components/SpaceJoinStatus.svelte" import {pushToast} from "@app/toast" import {goToSpace} from "@app/routes" + import {resyncApplicationData} from "@app/sync" import {relaysMostlyRestricted} from "@app/policies" import {notificationSettings, setSpaceNotifications} from "@app/settings" import {parseInviteLink} from "@app/invites" @@ -69,11 +70,13 @@ } await addSpace(url) - await goToSpace(url) - broadcastUserData([url]) - relaysMostlyRestricted.update(dissoc(url)) pushToast({message: "Welcome to the space!"}) + relaysMostlyRestricted.update(dissoc(url)) + resyncApplicationData() + broadcastUserData([url]) + + await goToSpace(url) } } diff --git a/src/app/components/SpaceJoin.svelte b/src/app/components/SpaceJoin.svelte index 626b5369..0a2bbb7a 100644 --- a/src/app/components/SpaceJoin.svelte +++ b/src/app/components/SpaceJoin.svelte @@ -16,6 +16,7 @@ import SpaceJoinStatus from "@app/components/SpaceJoinStatus.svelte" import {attemptRelayAccess} from "@app/relays" import {addSpace} from "@app/groups" + import {resyncApplicationData} from "@app/sync" import {broadcastUserData} from "@app/profiles" import {setSpaceNotifications} from "@app/settings" import {relaysMostlyRestricted} from "@app/policies" @@ -56,11 +57,13 @@ } await addSpace(url) - await goToSpace(url) - broadcastUserData([url]) - relaysMostlyRestricted.update(dissoc(url)) pushToast({message: "Welcome to the space!"}) + relaysMostlyRestricted.update(dissoc(url)) + resyncApplicationData() + broadcastUserData([url]) + + await goToSpace(url) } catch (e) { console.error("Failed to join space:", e) pushToast({theme: "error", message: "Failed to join space. Please try again."}) diff --git a/src/app/sync.ts b/src/app/sync.ts index 5dd0192c..f53a743c 100644 --- a/src/app/sync.ts +++ b/src/app/sync.ts @@ -457,8 +457,17 @@ const syncDMs = () => { // Merge all synchronization functions +let unsubscribe: Unsubscriber + export const syncApplicationData = () => { const unsubscribers = [syncRelays(), syncUserData(), syncSpaces(), syncDMs()] - return () => unsubscribers.forEach(call) + unsubscribe = () => unsubscribers.forEach(call) + + return unsubscribe +} + +export const resyncApplicationData = () => { + unsubscribe?.() + syncApplicationData() }