diff --git a/front/src/Components/FollowMenu/FollowMenu.svelte b/front/src/Components/FollowMenu/FollowMenu.svelte index 59194db2..6506b1d6 100644 --- a/front/src/Components/FollowMenu/FollowMenu.svelte +++ b/front/src/Components/FollowMenu/FollowMenu.svelte @@ -18,40 +18,6 @@ vim: ft=typescript const gameScene = gameManager.getCurrentGameScene(); - let followState: string; - let followRole: string; - let followUsers: number[]; - let stateUnsubscriber: Unsubscriber; - let roleUnsubscriber: Unsubscriber; - let nameUnsubscriber: Unsubscriber; - - onMount(() => { - followState = get(followStateStore); - followRole = get(followRoleStore); - followUsers = get(followUsersStore); - stateUnsubscriber = followStateStore.subscribe((state) => { - followState = state; - }); - roleUnsubscriber = followRoleStore.subscribe((role) => { - followRole = role; - }); - nameUnsubscriber = followUsersStore.subscribe((users) => { - followUsers = users; - }); - }); - - onDestroy(() => { - if (stateUnsubscriber) { - stateUnsubscriber(); - } - if (roleUnsubscriber) { - roleUnsubscriber(); - } - if (nameUnsubscriber) { - nameUnsubscriber(); - } - }); - function name(userId: number): string | undefined { return gameScene.MapPlayersByKey.get(userId)?.PlayerValue; } @@ -85,11 +51,11 @@ vim: ft=typescript -{#if followState === followStates.requesting} +{#if $followStateStore === followStates.requesting}
- {#if followRole === followRoles.follower} + {#if $followRoleStore === followRoles.follower}
-

Do you want to follow {name(followUsers[0])}?

+

Do you want to follow {name($followUsersStore[0])}?

- {:else if followRole === followRoles.leader} + {:else if $followRoleStore === followRoles.leader}

Should never be displayed

@@ -105,16 +71,16 @@ vim: ft=typescript
{/if} -{#if followState === followStates.ending} +{#if $followStateStore === followStates.ending}

Interaction

- {#if followRole === followRoles.follower} + {#if $followRoleStore === followRoles.follower}
-

Do you want to stop following {name(followUsers[0])}?

+

Do you want to stop following {name($followUsersStore[0])}?

- {:else if followRole === followRoles.leader} + {:else if $followRoleStore === followRoles.leader}

Do you want to stop leading the way?

@@ -126,20 +92,20 @@ vim: ft=typescript
{/if} -{#if followState === followStates.active || followState === followStates.ending} +{#if $followStateStore === followStates.active || $followStateStore === followStates.ending}
- {#if followRole === followRoles.follower} -

Following {name(followUsers[0])}

- {:else if followUsers.length === 0} + {#if $followRoleStore === followRoles.follower} +

Following {name($followUsersStore[0])}

+ {:else if $followUsersStore.length === 0}

Waiting for followers' confirmation

- {:else if followUsers.length === 1} -

{name(followUsers[0])} is following you

- {:else if followUsers.length === 2} -

{name(followUsers[0])} and {name(followUsers[1])} are following you

+ {:else if $followUsersStore.length === 1} +

{name($followUsersStore[0])} is following you

+ {:else if $followUsersStore.length === 2} +

{name($followUsersStore[0])} and {name($followUsersStore[1])} are following you

{:else}

- {followUsers.slice(0, -1).map(name).join(", ")} and {name(followUsers[followUsers.length - 1])} are following + {$followUsersStore.slice(0, -1).map(name).join(", ")} and {name($followUsersStore[$followUsersStore.length - 1])} are following you

{/if} @@ -147,7 +113,7 @@ vim: ft=typescript
{/if} -{#if followState === followStates.off} +{#if $followStateStore === followStates.off}