From 00000a9bbd7bc6f706a1234baae90e9dff7a40f0 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Thu, 21 Dec 2023 15:57:50 -0500 Subject: [PATCH] make bgUrl work --- ui/src/AboutDialog.svelte | 6 ++---- ui/src/BoardMenu.svelte | 3 +-- ui/src/BoardMenuItem.svelte | 12 ++---------- ui/src/Controller.svelte | 5 ++--- ui/src/NewBoardDialog.svelte | 3 +-- ui/src/Team.svelte | 3 +-- ui/src/Toolbar.svelte | 6 ++---- ui/src/boardList.ts | 9 ++++++--- ui/src/store.ts | 29 +++++++++++++++++++++++++++++ 9 files changed, 46 insertions(+), 30 deletions(-) diff --git a/ui/src/AboutDialog.svelte b/ui/src/AboutDialog.svelte index c337a9f..712443b 100644 --- a/ui/src/AboutDialog.svelte +++ b/ui/src/AboutDialog.svelte @@ -18,8 +18,7 @@ const createBoardFrom = async (oldBoard: BoardState) => { const board = await store.boardList.cloneBoard(oldBoard) - store.setUIprops({showMenu:false}) - store.boardList.setActiveBoard(board.hash) + store.setActiveBoard(board.hash) } let fileinput; @@ -35,8 +34,7 @@ boards.push(await store.boardList.makeBoard(b)) } if (importedBoardStates.length == 1) { - store.setUIprops({showMenu:false}) - store.boardList.setActiveBoard(boards[0].hash) + store.setActiveBoard(boards[0].hash) } } importing = false diff --git a/ui/src/BoardMenu.svelte b/ui/src/BoardMenu.svelte index e5a9a12..14e220b 100644 --- a/ui/src/BoardMenu.svelte +++ b/ui/src/BoardMenu.svelte @@ -30,8 +30,7 @@ const selectBoard = async (hash: EntryHash) => { - store.setUIprops({showMenu:false}) - await store.boardList.setActiveBoard(hash) + await store.setActiveBoard(hash) } const unarchiveBoard = async (hash: EntryHash) => { diff --git a/ui/src/BoardMenuItem.svelte b/ui/src/BoardMenuItem.svelte index aaf383f..acf8335 100644 --- a/ui/src/BoardMenuItem.svelte +++ b/ui/src/BoardMenuItem.svelte @@ -18,14 +18,6 @@ export let boardHash: EntryHash export let boardType: BoardType - const archiveBoard = async () => { - await store.boardList.archiveBoard(boardHash) - } - - const unarchiveBoard = async () => { - await store.boardList.unarchiveBoard(boardHash) - } - const leaveBoard = async () => { await store.boardList.closeActiveBoard(true) }; @@ -59,8 +51,8 @@ on:sl-select={(e)=>{ switch(e.detail.item.value) { case "leave": leaveBoard(); break; - case "archive": archiveBoard(); break; - case "unarchive": unarchiveBoard(); break; + case "archive": store.archiveBoard(boardHash); break; + case "unarchive": store.unarchiveBoard(boardHash); break; case "export": exportBoard(latestState); break; } menu.hide() diff --git a/ui/src/Controller.svelte b/ui/src/Controller.svelte index 0137c2c..3167b38 100644 --- a/ui/src/Controller.svelte +++ b/ui/src/Controller.svelte @@ -34,8 +34,8 @@ getStore: () => store, }); const DEFAULT_KD_BG_IMG = "" - //const DEFAULT_KD_BG_IMG = "https://img.freepik.com/free-photo/studio-background-concept-abstract-empty-light-gradient-purple-studio-room-background-product-plain-studio-background_1258-54461.jpg" - const NO_BOARD_IMG = "https://holochain.org/img/big_logo.png" + // const DEFAULT_KD_BG_IMG = "https://img.freepik.com/free-photo/studio-background-concept-abstract-empty-light-gradient-purple-studio-room-background-product-plain-studio-background_1258-54461.jpg" + // const NO_BOARD_IMG = "https://holochain.org/img/big_logo.png" $: uiProps = store.uiProps $: bgUrl = $uiProps.bgUrl ? $uiProps.bgUrl : DEFAULT_KD_BG_IMG $: boardCount = store.boardList.boardCount @@ -76,7 +76,6 @@ {/if} - {#if $activeBoard !== undefined} {/if} diff --git a/ui/src/NewBoardDialog.svelte b/ui/src/NewBoardDialog.svelte index f446728..721ae41 100644 --- a/ui/src/NewBoardDialog.svelte +++ b/ui/src/NewBoardDialog.svelte @@ -19,8 +19,7 @@ // @ts-ignore const board = await store.boardList.makeBoard({name, groups, voteTypes, props, status:""}) dialog.hide() - store.setUIprops({showMenu:false}) - await store.boardList.setActiveBoard(board.hash) + await store.setActiveBoard(board.hash) } export const open = ()=> { boardEditor.reset() diff --git a/ui/src/Team.svelte b/ui/src/Team.svelte index ac643e2..f5d9565 100644 --- a/ui/src/Team.svelte +++ b/ui/src/Team.svelte @@ -35,8 +35,7 @@
{#each $agentBoards.value.get(agentPubKey) as board}
{ - store.boardList.setActiveBoard(board.board.hash) - store.setUIprops({showMenu:false}) + store.setActiveBoard(board.board.hash) }}>{board.latestState.name}
{/each}
diff --git a/ui/src/Toolbar.svelte b/ui/src/Toolbar.svelte index 9bbb834..fe30573 100644 --- a/ui/src/Toolbar.svelte +++ b/ui/src/Toolbar.svelte @@ -15,13 +15,11 @@ let editBoardDialog const closeBoard = async () => { - await store.boardList.closeActiveBoard(false) - store.setUIprops({showMenu:true}) + await store.closeActiveBoard(false) }; const leaveBoard = async () => { - await store.boardList.closeActiveBoard(true) - store.setUIprops({showMenu:true}) + await store.closeActiveBoard(true) }; diff --git a/ui/src/boardList.ts b/ui/src/boardList.ts index 2114b46..09f1c13 100644 --- a/ui/src/boardList.ts +++ b/ui/src/boardList.ts @@ -108,10 +108,10 @@ export class BoardList { return board.board } - async setActiveBoard(hash: EntryHash | undefined) { + async setActiveBoard(hash: EntryHash | undefined) : Promise { + let board: Board | undefined = undefined if (hash) { - const board = (await toPromise(this.boardData2.get(hash))).board - + board = (await toPromise(this.boardData2.get(hash))).board if (board) { await board.join() console.log("joined") @@ -123,6 +123,9 @@ export class BoardList { this.activeBoard.update((n) => {return undefined} ) } this.activeBoardHash.update((n) => {return hash} ) + console.log("C", board) + + return board } async archiveBoard(documentHash: EntryHash) { diff --git a/ui/src/store.ts b/ui/src/store.ts index ebb6101..4f5427c 100644 --- a/ui/src/store.ts +++ b/ui/src/store.ts @@ -64,6 +64,35 @@ export class TalkingStickiesStore { }) } + async setActiveBoard(hash: EntryHash | undefined) { + const board = await this.boardList.setActiveBoard(hash) + let bgUrl = "" + if (board) { + const state = board.state() + if (state) { + bgUrl = state.props.bgUrl + } + } + this.setUIprops({showMenu:false, bgUrl}) + } + + async closeActiveBoard(leave: boolean) { + await this.boardList.closeActiveBoard(leave) + this.setUIprops({showMenu:true, bgUrl:""}) + } + + + async archiveBoard(documentHash: EntryHash) { + const wasActive = this.boardList.archiveBoard(documentHash) + if (wasActive ) { + this.setUIprops({showMenu:true, bgUrl:""}) + } + } + + async unarchiveBoard(documentHash: EntryHash) { + this.boardList.unarchiveBoard(documentHash) + } + get myAgentPubKey(): AgentPubKey { return this.client.myPubKey; }