1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Switch board - attach listener to new board

This commit is contained in:
Chen-I Lim 2020-10-12 19:21:58 -07:00
parent c92f5a8ec0
commit 057007d21c

View File

@ -23,8 +23,8 @@ class BoardPage implements IPageController {
groupByButton: HTMLElement
groupByLabel: HTMLElement
boardId: string
viewId: string
boardId?: string
viewId?: string
workspaceTree: WorkspaceTree
boardTree: BoardTree
@ -52,18 +52,12 @@ class BoardPage implements IPageController {
this.workspaceTree = new WorkspaceTree(this.octo)
this.boardId = queryString.get("id")
this.viewId = queryString.get("v")
const boardId = queryString.get("id")
const viewId = queryString.get("v")
console.log(`BoardPage. boardId: ${this.boardId}`)
if (this.boardId) {
this.boardTree = new BoardTree(this.octo, this.boardId)
this.sync()
this.boardListener.open(this.boardId, (blockId: string) => {
console.log(`octoListener.onChanged: ${blockId}`)
this.sync()
})
if (boardId) {
this.attachToBoard(boardId, viewId)
} else {
// Show error
}
@ -185,6 +179,20 @@ class BoardPage implements IPageController {
}
}
private attachToBoard(boardId: string, viewId?: string) {
this.boardId = boardId
this.viewId = viewId
this.boardTree = new BoardTree(this.octo, boardId)
this.boardListener.open(boardId, (blockId: string) => {
console.log(`octoListener.onChanged: ${blockId}`)
this.sync()
})
this.sync()
}
async sync() {
const { workspaceTree, boardTree } = this
@ -228,13 +236,12 @@ class BoardPage implements IPageController {
}
showBoard(boardId: string) {
if (this.boardTree.board.id === boardId) { return }
if (this.boardTree?.board?.id === boardId) { return }
const newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + `?id=${encodeURIComponent(boardId)}`
window.history.pushState({ path: newUrl }, "", newUrl)
this.boardTree = new BoardTree(this.octo, boardId)
this.sync()
this.attachToBoard(boardId)
}
showView(viewId: string) {