mirror of
https://github.com/edufeed-org/educards.git
synced 2025-12-09 16:24:34 +00:00
Fix reloading on board address page
This commit is contained in:
parent
9522a062f5
commit
1a4a97ef89
3 changed files with 51 additions and 36 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "opencard",
|
||||
"name": "educards",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<h1 class="ml-5 text-lg">{eventTitle($currentBoard)}</h1>
|
||||
{#if $user && $user.pubkey === $currentBoard.pubkey}
|
||||
{#if userAndBoardMatch($user, $currentBoard)}
|
||||
<button class="btn mr-5" on:click={openColumnModal}>Add column</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
@ -75,40 +79,46 @@
|
|||
>
|
||||
{#each items as column (column.id)}
|
||||
<div class="column" animate:flip={{ duration: flipDurationMs }}>
|
||||
<div class="flex">
|
||||
<div class="column-title">{column.dTag}</div>
|
||||
{#if $user && $user.pubkey === $currentBoard.pubkey}
|
||||
<button class="btn btn-error ml-auto mr-0" on:click={() => deleteColumn(column.id)}
|
||||
>🗑️</button
|
||||
{#if column !== undefined}
|
||||
<div class="flex">
|
||||
<div class="column-title">{column.dTag}</div>
|
||||
{#if userAndBoardMatch($user, $currentBoard)}
|
||||
<button class="btn btn-error ml-auto mr-0" on:click={() => deleteColumn(column.id)}
|
||||
>🗑️</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex">
|
||||
{#if userAndBoardMatch($user, $currentBoard)}
|
||||
<button
|
||||
class="btn mx-auto"
|
||||
on:click={() => {
|
||||
// set selected columns
|
||||
$selectedColumn = column.dTag;
|
||||
openCardModal();
|
||||
}}>Add Card</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if column.items.every((e) => e !== undefined)}
|
||||
<div
|
||||
class="column-content"
|
||||
use:dndzone={{ items: column.items, flipDurationMs }}
|
||||
on:consider={(e) => handleDndConsiderCards(column.id, e)}
|
||||
on:finalize={(e) => handleDndFinalizeCards(column.id, e)}
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex">
|
||||
{#if $user && $user.pubkey === $currentBoard.pubkey}
|
||||
<button
|
||||
class="btn mx-auto"
|
||||
on:click={() => {
|
||||
// set selected columns
|
||||
$selectedColumn = column.dTag;
|
||||
openCardModal();
|
||||
}}>Add Card</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
<div
|
||||
class="column-content"
|
||||
use:dndzone={{ items: column.items, flipDurationMs }}
|
||||
on:consider={(e) => handleDndConsiderCards(column.id, e)}
|
||||
on:finalize={(e) => handleDndFinalizeCards(column.id, e)}
|
||||
>
|
||||
{#each column.items as item (item.id)}
|
||||
<div class="card" animate:flip={{ duration: flipDurationMs }}>
|
||||
{item.content}
|
||||
{item.dTag}
|
||||
<button on:click={() => deleteCard(column, item.id)}>Delete</button>
|
||||
<!-- {@debug column} -->
|
||||
{#each column.items as item (item?.id ?? item)}
|
||||
<div class="card" animate:flip={{ duration: flipDurationMs }}>
|
||||
{item.content}
|
||||
{item.dTag}
|
||||
<button on:click={() => deleteCard(column, item.id)}>Delete</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue