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,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,15 @@
|
||||||
const updatedColumnItems = column.items.filter((e) => e.id !== itemId);
|
const updatedColumnItems = column.items.filter((e) => e.id !== itemId);
|
||||||
publishCards({ ...column, items: updatedColumnItems });
|
publishCards({ ...column, items: updatedColumnItems });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function userAndBoardMatch(user, board) {
|
||||||
|
return user !== undefined && board && user?.pubkey === board?.pubkey;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row items-center justify-between">
|
<div class="flex flex-row items-center justify-between">
|
||||||
<h1 class="ml-5 text-lg">{eventTitle($currentBoard)}</h1>
|
<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>
|
<button class="btn mr-5" on:click={openColumnModal}>Add column</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -75,40 +79,46 @@
|
||||||
>
|
>
|
||||||
{#each items as column (column.id)}
|
{#each items as column (column.id)}
|
||||||
<div class="column" animate:flip={{ duration: flipDurationMs }}>
|
<div class="column" animate:flip={{ duration: flipDurationMs }}>
|
||||||
<div class="flex">
|
{#if column !== undefined}
|
||||||
<div class="column-title">{column.dTag}</div>
|
<div class="flex">
|
||||||
{#if $user && $user.pubkey === $currentBoard.pubkey}
|
<div class="column-title">{column.dTag}</div>
|
||||||
<button class="btn btn-error ml-auto mr-0" on:click={() => deleteColumn(column.id)}
|
{#if userAndBoardMatch($user, $currentBoard)}
|
||||||
>🗑️</button
|
<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}
|
<!-- {@debug column} -->
|
||||||
</div>
|
{#each column.items as item (item?.id ?? item)}
|
||||||
<div class="flex">
|
<div class="card" animate:flip={{ duration: flipDurationMs }}>
|
||||||
{#if $user && $user.pubkey === $currentBoard.pubkey}
|
{item.content}
|
||||||
<button
|
{item.dTag}
|
||||||
class="btn mx-auto"
|
<button on:click={() => deleteCard(column, item.id)}>Delete</button>
|
||||||
on:click={() => {
|
</div>
|
||||||
// set selected columns
|
{/each}
|
||||||
$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>
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/if}
|
||||||
</div>
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,11 @@ export async function login(method) {
|
||||||
const ndk = get(db).ndk;
|
const ndk = get(db).ndk;
|
||||||
ndk.signer = nip07signer;
|
ndk.signer = nip07signer;
|
||||||
|
|
||||||
|
let user = {};
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'browser-extension': {
|
case 'browser-extension': {
|
||||||
console.log('login with extension');
|
console.log('login with extension');
|
||||||
const user = await nip07signer.user();
|
user = await nip07signer.user();
|
||||||
userStore.set(user);
|
userStore.set(user);
|
||||||
console.log('user', user);
|
console.log('user', user);
|
||||||
db.update((db) => {
|
db.update((db) => {
|
||||||
|
|
@ -103,8 +104,12 @@ async function eventTagToColumn(eventTag) {
|
||||||
return { id: d, title, items, event };
|
return { id: d, title, items, event };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {NDKEvent} event
|
||||||
|
*/
|
||||||
export function eventTitle(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;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue