diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-11-06 14:11:57 -0500 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-11-06 14:11:57 -0500 |
| commit | 91ce856f63bd1d7a188488476bdbec60b5bd58ff (patch) | |
| tree | eb10eff2c50de1f7cfee86a203fdbeda9b0ebc93 /ui/routes/(app) | |
| parent | 1614fea76a6fc1f4d70ddb14b95e3004c79365ef (diff) | |
| parent | 1776711aaad56efe67365d69e2e9f8aa76ee67ef (diff) | |
Merge branch 'main' into wip/touch-events
Diffstat (limited to 'ui/routes/(app)')
| -rw-r--r-- | ui/routes/(app)/+layout.svelte | 7 | ||||
| -rw-r--r-- | ui/routes/(app)/me/+page.svelte | 17 |
2 files changed, 20 insertions, 4 deletions
diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index acaea53..84090e7 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -1,16 +1,17 @@ <script> import { page } from '$app/stores'; import { goto } from '$app/navigation'; - import { onMount, onDestroy } from 'svelte'; + import { onMount, onDestroy, getContext } from 'svelte'; import { boot, subscribeToEvents } from '$lib/apiServer'; - import { showMenu, currentUser, logins, channelsList, messages } from '$lib/store'; + import { currentUser, logins, channelsList, messages } from '$lib/store'; import ChannelList from '$lib/components/ChannelList.svelte'; import CreateChannelForm from '$lib/components/CreateChannelForm.svelte'; let events = null; + let pageContext = getContext('page'); let { children } = $props(); let loading = $state(true); let channel = $derived($page.params.channel); @@ -97,7 +98,7 @@ <h2>Loading…</h2> {:else} <div id="interface" class="p-2"> - <nav id="sidebar" data-expanded={$showMenu}> + <nav id="sidebar" data-expanded={pageContext.showMenu}> <div class="channel-list"> <ChannelList active={channel} channels={$channelsList.channels} /> </div> diff --git a/ui/routes/(app)/me/+page.svelte b/ui/routes/(app)/me/+page.svelte index 30da6f0..8d24a61 100644 --- a/ui/routes/(app)/me/+page.svelte +++ b/ui/routes/(app)/me/+page.svelte @@ -1,5 +1,7 @@ <script> - import { changePassword } from '$lib/apiServer.js'; + import { goto } from '$app/navigation'; + import { changePassword, logOut } from '$lib/apiServer.js'; + import { currentUser } from '$lib/store'; import Invites from '$lib/components/Invites.svelte'; @@ -11,6 +13,15 @@ let valid = $derived(newPassword === confirmPassword && newPassword !== currentPassword); let disabled = $derived(pending || !valid); + async function onLogOut(event) { + event.preventDefault(); + const response = await logOut(); + if (200 <= response.status && response.status < 300) { + currentUser.update(() => null); + goto('/login'); + } + } + async function onPasswordChange(event) { event.preventDefault(); pending = true; @@ -24,6 +35,10 @@ } </script> +<form onsubmit={onLogOut}> + <button class="btn variant-filled" type="submit">log out</button> +</form> + <form onsubmit={onPasswordChange} bind:this={passwordForm}> <label >current password |
