Add logout

This commit is contained in:
@s.roertgen 2025-04-15 15:21:09 +02:00
parent 08ad305cc2
commit 1f3234b799
4 changed files with 11 additions and 8 deletions

View file

@ -4,7 +4,7 @@
export let board; export let board;
</script> </script>
<div class="card w-96 flex-none bg-base-100 shadow-xl"> <div class="card w-96 bg-base-100 shadow-xl">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">{eventTitle(board)}</h2> <h2 class="card-title">{eventTitle(board)}</h2>
<div class="card-actions justify-end"> <div class="card-actions justify-end">

View file

@ -11,7 +11,7 @@
<div class="form-control"> <div class="form-control">
<!-- <input type="text" placeholder="Search" class="input input-bordered w-24 md:w-auto" /> --> <!-- <input type="text" placeholder="Search" class="input input-bordered w-24 md:w-auto" /> -->
</div> </div>
{#if $user} {#if $user?.pubkey}
<div class="dropdown dropdown-end"> <div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="avatar btn btn-circle btn-ghost"> <div tabindex="0" role="button" class="avatar btn btn-circle btn-ghost">
<div class="w-10 rounded-full"> <div class="w-10 rounded-full">
@ -29,7 +29,7 @@
</a> </a>
</li> </li>
<li><a>Settings</a></li> <li><a>Settings</a></li>
<li><a>Logout</a></li> <li><a onclick={() => user.set(null)}>Logout</a></li>
</ul> </ul>
</div> </div>
{:else} {:else}

View file

@ -63,8 +63,11 @@ export const cardsForColumn = (columnId) => {
export const user = writable(null); export const user = writable(null);
export const userBoards = derived([user, boards], ([$user, $boards]) => { export const userBoards = derived([user, boards], ([$user, $boards]) => {
const newUserBoards = $boards.filter((b) => b.pubkey === $user.pubkey); if ($user?.pubkey) {
return newUserBoards; const newUserBoards = $boards.filter((b) => b.pubkey === $user.pubkey);
return newUserBoards;
}
return [];
}); });
export const db = writable({ export const db = writable({
@ -86,9 +89,9 @@ async function initNDK() {
const subDelete = ndk.subscribe({ kinds: [5] }); const subDelete = ndk.subscribe({ kinds: [5] });
subDelete.on('event', async (event) => { subDelete.on('event', async (event) => {
const toBeDeletedDs = event.getMatchingTags('a').map((e) => e[1].split(':')[2]); const toBeDeletedDs = event.getMatchingTags('a').map((e) => e[1]);
events.update((events) => { events.update((events) => {
return events.filter((e) => !toBeDeletedDs.includes(e.dTag)); return events.filter((e) => !toBeDeletedDs.includes(e.tagAddress()));
}); });
}); });

View file

@ -35,7 +35,7 @@
{#if $boards.length > 0} {#if $boards.length > 0}
<h1 class="mx-auto text-lg">Alle Boards</h1> <h1 class="mx-auto text-lg">Alle Boards</h1>
<div class="flex flex-wrap justify-start gap-2"> <div class="flex grid grid-flow-col grid-rows-2 overflow-y-auto">
{#if $user} {#if $user}
{#each $boards.filter((e) => e.pubkey !== $user.pubkey) as board (board.id)} {#each $boards.filter((e) => e.pubkey !== $user.pubkey) as board (board.id)}
<BoardCard {board} /> <BoardCard {board} />