diff --git a/package.json b/package.json index ec97f00..9a04b62 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "opencard", + "name": "educards", "private": true, "version": "0.0.1", "type": "module", diff --git a/src/lib/components/Board.svelte b/src/lib/components/Board.svelte index dd81375..b2a5665 100644 --- a/src/lib/components/Board.svelte +++ b/src/lib/components/Board.svelte @@ -59,11 +59,15 @@ const updatedColumnItems = column.items.filter((e) => e.id !== itemId); publishCards({ ...column, items: updatedColumnItems }); } + + function userAndBoardMatch(user, board) { + return user !== undefined && board && user?.pubkey === board?.pubkey; + }

{eventTitle($currentBoard)}

- {#if $user && $user.pubkey === $currentBoard.pubkey} + {#if userAndBoardMatch($user, $currentBoard)} {/if}
@@ -75,40 +79,46 @@ > {#each items as column (column.id)}
-
-
{column.dTag}
- {#if $user && $user.pubkey === $currentBoard.pubkey} - +
{column.dTag}
+ {#if userAndBoardMatch($user, $currentBoard)} + + {/if} +
+
+ {#if userAndBoardMatch($user, $currentBoard)} + + {/if} +
+ + {#if column.items.every((e) => e !== undefined)} +
handleDndConsiderCards(column.id, e)} + on:finalize={(e) => handleDndFinalizeCards(column.id, e)} > - {/if} -
-
- {#if $user && $user.pubkey === $currentBoard.pubkey} - - {/if} -
-
handleDndConsiderCards(column.id, e)} - on:finalize={(e) => handleDndFinalizeCards(column.id, e)} - > - {#each column.items as item (item.id)} -
- {item.content} - {item.dTag} - + + {#each column.items as item (item?.id ?? item)} +
+ {item.content} + {item.dTag} + +
+ {/each}
- {/each} -
+ {/if} + {/if}
{/each} diff --git a/src/lib/ndk.js b/src/lib/ndk.js index e3113de..cdd796e 100644 --- a/src/lib/ndk.js +++ b/src/lib/ndk.js @@ -15,10 +15,11 @@ export async function login(method) { const ndk = get(db).ndk; ndk.signer = nip07signer; + let user = {}; switch (method) { case 'browser-extension': { console.log('login with extension'); - const user = await nip07signer.user(); + user = await nip07signer.user(); userStore.set(user); console.log('user', user); db.update((db) => { @@ -103,8 +104,12 @@ async function eventTagToColumn(eventTag) { return { id: d, title, items, event }; } +/** + * @param {NDKEvent} event + */ export function eventTitle(event) { - const title = event.tags.find((e) => e[0] === 'title')[1]; + if (event === undefined) return ''; + const title = event.tags.find((e) => e[0] === 'title')[1] ?? ''; return title; }