Skip to content

Commit

Permalink
make bgUrl work
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy committed Dec 21, 2023
1 parent 280bba9 commit 00000a9
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 30 deletions.
6 changes: 2 additions & 4 deletions ui/src/AboutDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions ui/src/BoardMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 2 additions & 10 deletions ui/src/BoardMenuItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions ui/src/Controller.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +76,6 @@
</div>
{/if}


{#if $activeBoard !== undefined}
<TalkingStickiesPane activeBoard={$activeBoard}/>
{/if}
Expand Down
3 changes: 1 addition & 2 deletions ui/src/NewBoardDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions ui/src/Team.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<div class="boards">
{#each $agentBoards.value.get(agentPubKey) as board}
<div class="board" on:click={()=>{
store.boardList.setActiveBoard(board.board.hash)
store.setUIprops({showMenu:false})
store.setActiveBoard(board.board.hash)
}}>{board.latestState.name}</div>
{/each}
</div>
Expand Down
6 changes: 2 additions & 4 deletions ui/src/Toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
</script>
Expand Down
9 changes: 6 additions & 3 deletions ui/src/boardList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export class BoardList {
return board.board
}

async setActiveBoard(hash: EntryHash | undefined) {
async setActiveBoard(hash: EntryHash | undefined) : Promise<Board | undefined> {
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")
Expand All @@ -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) {
Expand Down
29 changes: 29 additions & 0 deletions ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 00000a9

Please sign in to comment.