diff --git a/dist/index.js b/dist/index.js index 8ac2d9e8..8188c295 100644 --- a/dist/index.js +++ b/dist/index.js @@ -579,6 +579,9 @@ getBasePath = () => { return this.fileModel.getModelContainerPath("tasks" /* ModelTask */); }; + getViewPath = () => { + return [...this.getBasePath(), "view" /* ModelView */]; + }; getBoardFilePath = (boardId) => { return [...this.fileModel.getFilePath(boardId)]; }; @@ -1411,6 +1414,7 @@ // src/ViewModel/Pages/boardViewModel.ts var BoardViewModel = class { + storageModel; taskPageViewModel; // state boardInfo; @@ -1424,6 +1428,13 @@ "list" /* List */ ); index = new State(0); + // paths + getBasePath = () => { + return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)]; + }; + getLastUsedBoardPath = () => { + return [...this.getBasePath(), "last-used-view" /* LastUsedView */]; + }; // view select = () => { this.taskPageViewModel.selectBoard(this); @@ -1470,15 +1481,29 @@ this.taskPageViewModel.deleteBoard(this.boardInfo); this.close(); }; + // store + storeLastUsedView = () => { + const path = this.getLastUsedBoardPath(); + const lastUsedView = this.selectedPage.value; + this.storageModel.write(path, lastUsedView); + }; + restoreLastUsedView = () => { + const path = this.getLastUsedBoardPath(); + const lastUsedView = this.storageModel.read(path); + if (lastUsedView == null) return; + this.selectedPage.value = lastUsedView; + }; // load loadListRelevantData = () => { this.name.value = this.boardInfo.name; this.color.value = this.boardInfo.color; }; loadData = () => { + this.restoreLastUsedView(); }; // init - constructor(taskPageViewModel, boardInfo) { + constructor(taskPageViewModel, boardInfo, storageModel2) { + this.storageModel = storageModel2; this.taskPageViewModel = taskPageViewModel; this.boardInfo = boardInfo; this.loadListRelevantData(); @@ -1490,6 +1515,9 @@ if (this.isSelected.value == false) return; this.applyColor(); }); + this.selectedPage.subscribeSilent(() => { + this.storeLastUsedView(); + }); } }; @@ -1504,7 +1532,10 @@ ); // paths getBasePath = () => { - return [...this.taskModel.getBasePath()]; + return [...this.taskModel.getViewPath()]; + }; + getBoardViewPath = (boardId) => { + return [...this.getBasePath(), boardId]; }; getLastUsedBoardPath = () => { return [...this.getBasePath(), "last-used-board" /* LastUsedBoard */]; @@ -1543,7 +1574,11 @@ }; // view showBoardInList = (boardInfo) => { - const boardViewModel = new BoardViewModel(this, boardInfo); + const boardViewModel = new BoardViewModel( + this, + boardInfo, + this.storageModel + ); this.boardViewModels.set(boardInfo.fileId, boardViewModel); }; selectBoard = (boardViewModel) => { @@ -2201,6 +2236,7 @@ // src/View/ChatPages/boardPage.tsx function BoardPage(boardViewModel) { + boardViewModel.loadData(); return /* @__PURE__ */ createElement("div", { class: "pane" }, /* @__PURE__ */ createElement("div", { class: "toolbar" }, /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement( "button", { diff --git a/src/Model/Files/fileModel.ts b/src/Model/Files/fileModel.ts index f010cd0e..fe45f94f 100644 --- a/src/Model/Files/fileModel.ts +++ b/src/Model/Files/fileModel.ts @@ -170,6 +170,7 @@ export default class FileModel { export enum FileModelSubPath { Data = "data", Model = "model", + ModelView = "view", ModelTask = "tasks", }; diff --git a/src/Model/Files/taskModel.ts b/src/Model/Files/taskModel.ts index 38e7813c..511a5131 100644 --- a/src/Model/Files/taskModel.ts +++ b/src/Model/Files/taskModel.ts @@ -26,6 +26,10 @@ export default class TaskModel { return this.fileModel.getModelContainerPath(FileModelSubPath.ModelTask); }; + getViewPath = (): string[] => { + return [...this.getBasePath(), FileModelSubPath.ModelView]; + }; + getBoardFilePath = (boardId: string): string[] => { return [...this.fileModel.getFilePath(boardId)]; }; @@ -222,7 +226,7 @@ export default class TaskModel { export enum TaskModelSubPaths { Boards = "boards", BoardTasks = "tasks", -}; +} // types export interface BoardInfoFileContent extends FileContent<"board-info"> { diff --git a/src/View/ChatPages/boardPage.tsx b/src/View/ChatPages/boardPage.tsx index c042965d..3c855a75 100644 --- a/src/View/ChatPages/boardPage.tsx +++ b/src/View/ChatPages/boardPage.tsx @@ -9,6 +9,8 @@ import { BoardViewToggleButton } from "../Components/boardViewToggleButton"; import { translations } from "../translations"; export function BoardPage(boardViewModel: BoardViewModel) { + boardViewModel.loadData(); + return (