Skip to content

Commit 11b3f66

Browse files
committed
feat(web): show logged out view in main app page
Show a logged out friendly message and prompt if user is not logged in. Previously checked for recent projects regardless of login state.
1 parent 17185ca commit 11b3f66

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

apps/web/src/routes/(app)/+page.svelte

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { AUTH_SERVICE } from '$lib/auth/authService.svelte';
34
import DashboardLayout from '$lib/components/dashboard/DashboardLayout.svelte';
5+
import { USER_SERVICE } from '$lib/user/userService';
46
import { inject } from '@gitbutler/shared/context';
57
import { isFound } from '@gitbutler/shared/network/loadable';
68
import { getRecentlyPushedProjects } from '@gitbutler/shared/organizations/projectsPreview.svelte';
79
import { WEB_ROUTES_SERVICE } from '@gitbutler/shared/routing/webRoutes.svelte';
810
import { Button } from '@gitbutler/ui';
911
12+
const authService = inject(AUTH_SERVICE);
13+
const persistedToken = authService.token;
14+
1015
const routes = inject(WEB_ROUTES_SERVICE);
16+
const userService = inject(USER_SERVICE);
17+
const user = userService.user;
18+
19+
const loggedIn = $derived($user !== undefined);
1120
const recentProjects = getRecentlyPushedProjects();
1221
let hasRecentProjects = $state(false);
1322
@@ -25,9 +34,18 @@
2534
}
2635
}
2736
});
37+
38+
$effect(() => {
39+
if (!loggedIn && persistedToken.current) {
40+
// Clear any stale tokens if the user is not logged in
41+
authService.clearToken();
42+
}
43+
});
2844
</script>
2945

30-
{#if hasRecentProjects}
46+
{#if !loggedIn}
47+
<p>Loading...</p>
48+
{:else if hasRecentProjects}
3149
<DashboardLayout>
3250
<p>You have no recent projects!</p>
3351
</DashboardLayout>

0 commit comments

Comments
 (0)