Skip to content

Commit ae4d93d

Browse files
committed
Navigates to app route before updating state
Ensures the application navigates to the main app route before updating the organization state during impersonation or when stopping impersonation. This resolves potential issues where the state update might occur before the route is fully loaded, leading to inconsistent behavior.
1 parent cd309dc commit ae4d93d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Exceptionless.Web/ClientApp/src/lib/features/organizations/components/notifications/impersonation-notification.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import type { NotificationProps } from '$comp/notification';
33
import type { ViewOrganization } from '$features/organizations/models';
44
5+
import { goto } from '$app/navigation';
6+
import { resolve } from '$app/paths';
57
import { Notification, NotificationDescription, NotificationTitle } from '$comp/notification';
68
import { Button } from '$comp/ui/button';
79
import { organization } from '$features/organizations/context.svelte';
@@ -14,7 +16,8 @@
1416
1517
let { name, userOrganizations, ...restProps }: Props = $props();
1618
17-
function stopImpersonating() {
19+
async function stopImpersonating(): Promise<void> {
20+
await goto(resolve('/(app)'));
1821
organization.current = userOrganizations[0]?.id;
1922
}
2023
</script>

src/Exceptionless.Web/ClientApp/src/routes/(app)/(components)/layouts/sidebar-organization-switcher.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@
4848
}
4949
5050
async function handleImpersonate(organization: ViewOrganization): Promise<void> {
51-
currentOrganizationId = organization.id;
5251
await goto(resolve('/(app)'));
52+
currentOrganizationId = organization.id;
5353
}
5454
55-
function stopImpersonating(): void {
55+
async function stopImpersonating(): Promise<void> {
56+
await goto(resolve('/(app)'));
5657
currentOrganizationId = organizations[0]?.id;
5758
}
5859
</script>

src/Exceptionless.Web/ClientApp/src/routes/(app)/(components)/layouts/sidebar-user.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@
4747
}
4848
4949
async function impersonateOrganization(vo: ViewOrganization): Promise<void> {
50-
organization.current = vo.id;
5150
await goto(resolve('/(app)'));
51+
organization.current = vo.id;
5252
}
5353
5454
async function stopImpersonating(): Promise<void> {
55+
await goto(resolve('/(app)'));
5556
organization.current = organizations[0]?.id;
5657
}
5758
</script>

0 commit comments

Comments
 (0)