From c2da7f4c9b7de19e7eb7f2465356115e50edd6de Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Mon, 13 Apr 2026 19:45:52 +0000 Subject: [PATCH] fix board context management, cleanup --- bun.lockb | Bin 12416 -> 12416 bytes dist/index.js | 75 ++++++++---------- package.json | 4 +- src/View/Components/chatViewToggleButton.tsx | 2 +- src/View/chatPage.tsx | 2 - src/ViewModel/Chat/chatViewModel.ts | 9 +-- src/ViewModel/Global/coreViewModel.ts | 3 +- src/ViewModel/Global/fileTransferViewModel.ts | 4 +- src/ViewModel/Global/notificationViewModel.ts | 2 +- src/ViewModel/Global/settingsViewModel.ts | 4 +- src/ViewModel/Global/storageViewModel.ts | 4 +- src/ViewModel/Pages/boardViewModel.ts | 4 +- src/ViewModel/Pages/calendarPageViewModel.ts | 4 +- src/ViewModel/Pages/homeViewModel.ts | 4 +- src/ViewModel/Pages/messagePageViewModel.ts | 4 +- src/ViewModel/Pages/settingsPageViewModel.ts | 4 +- .../Pages/taskContainingPageViewModel.ts | 3 +- src/ViewModel/Pages/taskPageViewModel.ts | 15 ++-- src/ViewModel/Pages/taskViewModel.ts | 5 +- 19 files changed, 63 insertions(+), 89 deletions(-) diff --git a/bun.lockb b/bun.lockb index eec189599f547b3df2f5b91c38e0990f59514b28..d05422a5e2adf717631e4fd7517de14c42313a9a 100755 GIT binary patch literal 12416 zcmeI23p`X?+rS4~q#}1wQgSKHFhj~E_o#H_l2l3zLnDUFj9bx^P)b6F>f};M7mA|} zT~5*Es7@u_e3c|B@)BJsoP2A|>@_obJLf&qH{b8~z3ih|wl;QUn5FOL@ZSwo?0e@41{a zgNo`D9|`h@+;P)?@>DL~Q`?yM__Z;(38aZUL6H4Ia&TQs2fyG8Hk%#<6;1Fvnn2*t zm{c}BEQnAhNg${LeK(M5Kqlcb9G5=0w8!OiAXUMA8bGQ5iQ)3K1W$jA%d5CNiOWJ< zZo_39kjmisU|f3P(hip-AeBJ*cwEZi@*}Vx=C|Q;6p#u)NA&|L0px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GzyrOy)#! z|E>Ya0o3123z5;H%3y|wu5okZ%NfuH5d>yN zMB&dF5r&@|CPy@GfFimcCIk0800oyDAqVvekw(%l@nixfi8I5rNHCqjkE$;o5@dhRY4tCggTN3cCI>#wT7G0DMvc{3Liff^H6U(?|?v1a;WH8s8E9 iZ+tbJs|c)so*>T06F8d$Lbzw7Tf!2yC(8f3$^Qb?tXe(* diff --git a/dist/index.js b/dist/index.js index 3d5691ab..56cce1a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,9 +1,10 @@ (() => { - // ../../bloatless-react/index.ts + // node_modules/bloatless-react/index.ts var State = class { + _value; + _bindings = /* @__PURE__ */ new Set(); // init constructor(initialValue) { - this._bindings = /* @__PURE__ */ new Set(); this._value = initialValue; } // value @@ -31,11 +32,11 @@ } }; var ListState = class extends State { + additionHandlers = /* @__PURE__ */ new Set(); + removalHandlers = /* @__PURE__ */ new Map(); // init constructor(initialItems) { super(new Set(initialItems)); - this.additionHandlers = /* @__PURE__ */ new Set(); - this.removalHandlers = /* @__PURE__ */ new Map(); } // list add(...items) { @@ -75,11 +76,11 @@ } }; var MapState = class extends State { + additionHandlers = /* @__PURE__ */ new Set(); + removalHandlers = /* @__PURE__ */ new Map(); // init constructor(initialItems) { super(new Map(initialItems)); - this.additionHandlers = /* @__PURE__ */ new Set(); - this.removalHandlers = /* @__PURE__ */ new Map(); } // list set(key, item) { @@ -120,7 +121,7 @@ function createProxyState(statesToSubscibe, fn) { const proxyState = new State(fn()); statesToSubscibe.forEach( - (state) => state.subscribe(() => proxyState.value = fn()) + (state) => state.subscribeSilent(() => proxyState.value = fn()) ); return proxyState; } @@ -2254,7 +2255,7 @@ this.connectionModel = connectionModel2; this.chatListModel = chatListModel2; this.fileTransferModel = fileTransferModel2; - this.BUILD = "Build 26.04.13.B"; + this.BUILD = "Build 26.04.13.C"; // CONTEXT this.contextStack = /* @__PURE__ */ new Map(); this.logContexts = () => { @@ -2314,7 +2315,8 @@ } }; var Context = class { - constructor() { + constructor(contextDebugDescription) { + this.contextDebugDescription = contextDebugDescription; this.contextId = v4_default(); this.keystrokes = /* @__PURE__ */ new Map(); this.handleKeystroke = (e) => { @@ -2393,13 +2395,12 @@ var TaskViewModel = class extends Context { // init constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, containingModel, task) { - super(); + super("task"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; this.boardsAndTasksModel = boardsAndTasksModel; this.containingModel = containingModel; this.task = task; - this.contextDebugDescription = "task"; // paths this.getFilePath = () => { return this.boardsAndTasksModel.getTaskFilePath(this.task.fileId); @@ -2565,8 +2566,8 @@ // src/ViewModel/Pages/taskContainingPageViewModel.ts var TaskContainingPageViewModel = class extends Context { // init - constructor(coreViewModel2, chatViewModel, boardsAndTasksModel) { - super(); + constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, contextDebugDescription) { + super(contextDebugDescription); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; this.boardsAndTasksModel = boardsAndTasksModel; @@ -2614,12 +2615,11 @@ var CalendarPageViewModel = class extends TaskContainingPageViewModel { // init constructor(coreViewModel2, chatViewModel, calendarModel, boardsAndTasksModel) { - super(coreViewModel2, chatViewModel, boardsAndTasksModel); + super(coreViewModel2, chatViewModel, boardsAndTasksModel, "calendar"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; this.calendarModel = calendarModel; this.boardsAndTasksModel = boardsAndTasksModel; - this.contextDebugDescription = "calendar"; // paths this.getBasePath = () => { return [...this.calendarModel.getViewPath()]; @@ -2960,10 +2960,9 @@ var MessagePageViewModel = class extends Context { // init constructor(coreViewModel2, chatViewModel) { - super(); + super("message-page"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; - this.contextDebugDescription = "message-page"; // state this.chatMessageViewModels = new MapState(); this.filteredMessageViewModels = new ListState(); @@ -3070,10 +3069,9 @@ var SettingsPageViewModel = class extends Context { // init constructor(coreViewModel2, chatViewModel) { - super(); + super("settings"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; - this.contextDebugDescription = "settings"; // state this.primaryChannel = new State(""); this.primaryChannelInput = new State(""); @@ -3164,13 +3162,12 @@ var BoardViewModel = class extends TaskContainingPageViewModel { // init constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, taskPageViewModel, boardInfo) { - super(coreViewModel2, chatViewModel, boardsAndTasksModel); + super(coreViewModel2, chatViewModel, boardsAndTasksModel, "board"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; this.boardsAndTasksModel = boardsAndTasksModel; this.taskPageViewModel = taskPageViewModel; this.boardInfo = boardInfo; - this.contextDebugDescription = "board"; // state this.name = new State(""); this.color = new State("standard" /* Standard */); @@ -3396,11 +3393,10 @@ var TaskPageViewModel = class extends ContextHost { // init constructor(coreViewModel2, chatViewModel, boardsAndTasksModel) { - super(); + super("task-page"); this.coreViewModel = coreViewModel2; this.chatViewModel = chatViewModel; this.boardsAndTasksModel = boardsAndTasksModel; - this.contextDebugDescription = "task-page"; // data this.boardIndexManager = new IndexManager( (boardViewModel) => boardViewModel.name.value @@ -3496,6 +3492,8 @@ }; // load this.loadData = () => { + console.log("LOADING TASK PAGE DATA"); + this.closeContext(); this.boardViewModels.clear(); const boardIds = this.boardsAndTasksModel.listBoardIds(); for (const boardId of boardIds) { @@ -3509,14 +3507,17 @@ this.chatViewModel = chatViewModel; this.chatViewModel.registerContext("tasks" /* Tasks */, this); this.selectedBoardId.subscribeSilent(this.updateContexts); - this.loadData(); boardsAndTasksModel.boardHandlerManager.addHandler( (boardInfoFileContent) => { this.showBoardInList(boardInfoFileContent); this.updateBoardIndices(); - this.updateContexts(); } ); + this.chatViewModel.currentContext.subscribeSilent((context) => { + if (!this.isOpen) return; + if (context != this) return; + this.openLastUsedBoard(); + }); this.registerKeyStroke("." /* Options */, this.toggleBoardList); } // context @@ -3532,14 +3533,13 @@ var ChatViewModel6 = class extends ContextHost { // init constructor(coreViewModel2, chatModel, settingsViewModel2, notificationViewModel, connectionViewModel2, chatListViewModel2) { - super(); + super("chat"); this.coreViewModel = coreViewModel2; this.chatModel = chatModel; this.settingsViewModel = settingsViewModel2; this.notificationViewModel = notificationViewModel; this.connectionViewModel = connectionViewModel2; this.chatListViewModel = chatListViewModel2; - this.contextDebugDescription = "chat"; // state this.displayedColor = new State("standard" /* Standard */); this.selectedPage = new State( @@ -3562,8 +3562,6 @@ this.closeContext(); this.selectedPage.value = page; }; - this.closeSubPages = () => { - }; this.setColor = (color) => { this.setDisplayedColor(color); this.chatModel.setColor(color); @@ -3586,7 +3584,7 @@ ); const lastUsedPage = this.coreViewModel.storageModel.read(path); if (lastUsedPage != null) { - this.selectedPage.value = lastUsedPage; + this.openPage(lastUsedPage); } this.selectedPage.subscribeSilent((newPage) => { this.coreViewModel.storageModel.write(path, newPage); @@ -3714,7 +3712,7 @@ (chat2) => chat2.chatModel.info.primaryChannel == notification.chat ); chat.open(); - chat.selectedPage.value = "messages" /* Messages */; + chat.openPage("messages" /* Messages */); }; // loop this.loop = () => { @@ -4288,7 +4286,7 @@ // src/View/Components/chatViewToggleButton.tsx function ChatViewToggleButton(label, icon, page, chatViewModel) { function select() { - chatViewModel.selectedPage.value = page; + chatViewModel.openPage(page); } const isSelected = createProxyState( [chatViewModel.selectedPage], @@ -5419,7 +5417,6 @@ const mainContent = createProxyState( [chatViewModel.selectedPage], () => { - chatViewModel.closeSubPages(); switch (chatViewModel.selectedPage.value) { case "settings" /* Settings */: { return SettingsPage( @@ -5974,9 +5971,8 @@ var FileTransferViewModel = class extends Context { // init constructor(coreViewModel2) { - super(); + super("file-transfer"); this.coreViewModel = coreViewModel2; - this.contextDebugDescription = "transfer"; // state this.presentedModal = new State(void 0); this.generalFileOptions = new ListState(); @@ -6691,9 +6687,8 @@ var SettingsViewModel = class _SettingsViewModel extends Context { // init constructor(coreViewModel2) { - super(); + super("settings"); this.coreViewModel = coreViewModel2; - this.contextDebugDescription = "settings"; // state this.username = new State(""); this.usernameInput = new State(""); @@ -6909,9 +6904,8 @@ var StorageViewModel = class extends Context { // init constructor(coreViewModel2) { - super(); + super("storage"); this.coreViewModel = coreViewModel2; - this.contextDebugDescription = "storage"; // state this.isShowingStorageModal = new State(false); this.selectedPath = new State( @@ -7318,13 +7312,12 @@ // src/ViewModel/Pages/homeViewModel.ts var HomeViewModel = class extends Context { constructor(coreViewModel2, settingsViewModel2, fileTransferViewModel2, storageViewModel2, connectionViewModel2) { - super(); + super("home"); this.coreViewModel = coreViewModel2; this.settingsViewModel = settingsViewModel2; this.fileTransferViewModel = fileTransferViewModel2; this.storageViewModel = storageViewModel2; this.connectionViewModel = connectionViewModel2; - this.contextDebugDescription = "home"; this.coreViewModel.context = this; this.registerKeyStroke( "," /* Settings */, diff --git a/package.json b/package.json index 95fb8dee..455f2629 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "dependencies": { "@types/uuid": "^10.0.0", - "bloatless-react": "^1.3.11", - "esbuild": "^0.23.0", + "bloatless-react": "1.3.14", + "esbuild": "^0.23.1", "udn-frontend": "^1.0.9", "uuid": "^10.0.0" }, diff --git a/src/View/Components/chatViewToggleButton.tsx b/src/View/Components/chatViewToggleButton.tsx index 2a01b28c..1557cb9f 100644 --- a/src/View/Components/chatViewToggleButton.tsx +++ b/src/View/Components/chatViewToggleButton.tsx @@ -13,7 +13,7 @@ export function ChatViewToggleButton( chatViewModel: ChatViewModel, ) { function select() { - chatViewModel.selectedPage.value = page; + chatViewModel.openPage(page); } const isSelected = React.createProxyState( diff --git a/src/View/chatPage.tsx b/src/View/chatPage.tsx index f15347b7..8aebe653 100644 --- a/src/View/chatPage.tsx +++ b/src/View/chatPage.tsx @@ -18,8 +18,6 @@ export function ChatPage( const mainContent = React.createProxyState( [chatViewModel.selectedPage], () => { - chatViewModel.closeSubPages(); - switch (chatViewModel.selectedPage.value) { case ChatPageTypes.Settings: { return SettingsPage( diff --git a/src/ViewModel/Chat/chatViewModel.ts b/src/ViewModel/Chat/chatViewModel.ts index baa41ced..f72c6785 100644 --- a/src/ViewModel/Chat/chatViewModel.ts +++ b/src/ViewModel/Chat/chatViewModel.ts @@ -26,8 +26,6 @@ import { v4 } from "uuid"; import { CommonKeys } from "../../View/keystrokes"; export default class ChatViewModel extends ContextHost { - contextDebugDescription = "chat"; - calendarViewModel: CalendarPageViewModel; taskPageViewModel: TaskPageViewModel; messagePageViewModel: MessagePageViewModel; @@ -58,6 +56,7 @@ export default class ChatViewModel extends ContextHost { open = (): void => { this.coreViewModel.context = this; this.chatListViewModel.openChat(this); + //this.selectedPage.callSubscriptions(); }; close = (): void => { @@ -70,8 +69,6 @@ export default class ChatViewModel extends ContextHost { this.selectedPage.value = page; }; - closeSubPages = (): void => {}; - setColor = (color: Colors): void => { this.setDisplayedColor(color); this.chatModel.setColor(color); @@ -100,7 +97,7 @@ export default class ChatViewModel extends ContextHost { const lastUsedPage: string | null = this.coreViewModel.storageModel.read(path); if (lastUsedPage != null) { - this.selectedPage.value = lastUsedPage as any; + this.openPage(lastUsedPage as ChatPageTypes); } this.selectedPage.subscribeSilent((newPage) => { @@ -152,7 +149,7 @@ export default class ChatViewModel extends ContextHost { public readonly connectionViewModel: ConnectionViewModel, public readonly chatListViewModel: ChatListViewModel, ) { - super(); + super("chat"); // page viewModels this.calendarViewModel = new CalendarPageViewModel( diff --git a/src/ViewModel/Global/coreViewModel.ts b/src/ViewModel/Global/coreViewModel.ts index 43237fda..4289ff6e 100644 --- a/src/ViewModel/Global/coreViewModel.ts +++ b/src/ViewModel/Global/coreViewModel.ts @@ -94,7 +94,6 @@ export default class CoreViewModel { export class Context { contextId = v4(); - contextDebugDescription: string; keystrokes = new Map void>(); handleKeystroke = (e: KeyboardEvent): boolean => { @@ -112,6 +111,8 @@ export class Context { registerKeyStroke = (key: string, fn: () => void): void => { this.keystrokes.set(key, fn); }; + + constructor(public contextDebugDescription: string) {} } export class ContextHost extends Context { diff --git a/src/ViewModel/Global/fileTransferViewModel.ts b/src/ViewModel/Global/fileTransferViewModel.ts index 7ec53498..3ca1b8a5 100644 --- a/src/ViewModel/Global/fileTransferViewModel.ts +++ b/src/ViewModel/Global/fileTransferViewModel.ts @@ -13,8 +13,6 @@ import CoreViewModel, { Context } from "./coreViewModel"; import { CommonKeys } from "../../View/keystrokes"; export default class FileTransferViewModel extends Context { - contextDebugDescription = "transfer"; - // state presentedModal: React.State = new React.State(undefined); @@ -173,7 +171,7 @@ export default class FileTransferViewModel extends Context { // init constructor(public readonly coreViewModel: CoreViewModel) { - super(); + super("file-transfer"); this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler( this.handleReceivedFile, diff --git a/src/ViewModel/Global/notificationViewModel.ts b/src/ViewModel/Global/notificationViewModel.ts index 0ee993c3..5616ce9d 100644 --- a/src/ViewModel/Global/notificationViewModel.ts +++ b/src/ViewModel/Global/notificationViewModel.ts @@ -42,7 +42,7 @@ export default class NotificationViewModel { (chat) => chat.chatModel.info.primaryChannel == notification.chat, ); chat.open(); - chat.selectedPage.value = ChatPageTypes.Messages; + chat.openPage(ChatPageTypes.Messages); }; // loop diff --git a/src/ViewModel/Global/settingsViewModel.ts b/src/ViewModel/Global/settingsViewModel.ts index ffddb8fe..99202a5a 100644 --- a/src/ViewModel/Global/settingsViewModel.ts +++ b/src/ViewModel/Global/settingsViewModel.ts @@ -5,8 +5,6 @@ import { Languages, ThemeSettings } from "../../Model/Global/settingsModel"; import { CommonKeys } from "../../View/keystrokes"; export default class SettingsViewModel extends Context { - contextDebugDescription = "settings"; - // state username: React.State = new React.State(""); usernameInput: React.State = new React.State(""); @@ -73,7 +71,7 @@ export default class SettingsViewModel extends Context { // init constructor(public readonly coreViewModel: CoreViewModel) { - super(); + super("settings"); this.username.value = coreViewModel.settingsModel.username; this.usernameInput.value = coreViewModel.settingsModel.username; diff --git a/src/ViewModel/Global/storageViewModel.ts b/src/ViewModel/Global/storageViewModel.ts index f7e0602c..2561d42d 100644 --- a/src/ViewModel/Global/storageViewModel.ts +++ b/src/ViewModel/Global/storageViewModel.ts @@ -8,8 +8,6 @@ import CoreViewModel, { Context } from "./coreViewModel"; import { CommonKeys } from "../../View/keystrokes"; export default class StorageViewModel extends Context { - contextDebugDescription = "storage"; - // state isShowingStorageModal: React.State = new React.State(false); selectedPath: React.State = new React.State( @@ -67,7 +65,7 @@ export default class StorageViewModel extends Context { // init constructor(public readonly coreViewModel: CoreViewModel) { - super(); + super("storage"); this.selectedFileName = React.createProxyState( [this.selectedPath], diff --git a/src/ViewModel/Pages/boardViewModel.ts b/src/ViewModel/Pages/boardViewModel.ts index 3cc9445d..d71f5f65 100644 --- a/src/ViewModel/Pages/boardViewModel.ts +++ b/src/ViewModel/Pages/boardViewModel.ts @@ -16,8 +16,6 @@ import TaskViewModel from "./taskViewModel"; import { CommonKeys } from "../../View/keystrokes"; export default class BoardViewModel extends TaskContainingPageViewModel { - contextDebugDescription = "board"; - // state name: React.State = new React.State(""); color: React.State = new React.State(Colors.Standard); @@ -255,7 +253,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel { public readonly taskPageViewModel: TaskPageViewModel, public readonly boardInfo: BoardInfoFileContent, ) { - super(coreViewModel, chatViewModel, boardsAndTasksModel); + super(coreViewModel, chatViewModel, boardsAndTasksModel, "board"); // load this.loadListRelevantData(); diff --git a/src/ViewModel/Pages/calendarPageViewModel.ts b/src/ViewModel/Pages/calendarPageViewModel.ts index fe7b047a..81a9e2eb 100644 --- a/src/ViewModel/Pages/calendarPageViewModel.ts +++ b/src/ViewModel/Pages/calendarPageViewModel.ts @@ -14,8 +14,6 @@ import { CommonKeys } from "../../View/keystrokes"; export const CALENDAR_EVENT_BOARD_ID = "events"; export default class CalendarPageViewModel extends TaskContainingPageViewModel { - contextDebugDescription = "calendar"; - // data get monthString(): string { return CalendarModel.getMonthString( @@ -190,7 +188,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { public readonly calendarModel: CalendarModel, public readonly boardsAndTasksModel: BoardsAndTasksModel, ) { - super(coreViewModel, chatViewModel, boardsAndTasksModel); + super(coreViewModel, chatViewModel, boardsAndTasksModel, "calendar"); this.calendarModel = calendarModel; this.boardsAndTasksModel = boardsAndTasksModel; diff --git a/src/ViewModel/Pages/homeViewModel.ts b/src/ViewModel/Pages/homeViewModel.ts index b5a5a741..424c67b6 100644 --- a/src/ViewModel/Pages/homeViewModel.ts +++ b/src/ViewModel/Pages/homeViewModel.ts @@ -6,8 +6,6 @@ import SettingsViewModel from "../Global/settingsViewModel"; import StorageViewModel from "../Global/storageViewModel"; export default class HomeViewModel extends Context { - contextDebugDescription = "home"; - constructor( public readonly coreViewModel: CoreViewModel, public readonly settingsViewModel: SettingsViewModel, @@ -15,7 +13,7 @@ export default class HomeViewModel extends Context { public readonly storageViewModel: StorageViewModel, public readonly connectionViewModel: ConnectionViewModel, ) { - super(); + super("home"); this.coreViewModel.context = this; diff --git a/src/ViewModel/Pages/messagePageViewModel.ts b/src/ViewModel/Pages/messagePageViewModel.ts index a8e9bf69..fc43c915 100644 --- a/src/ViewModel/Pages/messagePageViewModel.ts +++ b/src/ViewModel/Pages/messagePageViewModel.ts @@ -13,8 +13,6 @@ import { v4 } from "uuid"; import { CommonKeys } from "../../View/keystrokes"; export default class MessagePageViewModel extends Context { - contextDebugDescription = "message-page"; - // state chatMessageViewModels: React.MapState = new React.MapState(); @@ -130,7 +128,7 @@ export default class MessagePageViewModel extends Context { public readonly coreViewModel: CoreViewModel, public readonly chatViewModel: ChatViewModel, ) { - super(); + super("message-page"); // states this.cannotSendMessage = React.createProxyState( diff --git a/src/ViewModel/Pages/settingsPageViewModel.ts b/src/ViewModel/Pages/settingsPageViewModel.ts index ac19b879..1a9c0312 100644 --- a/src/ViewModel/Pages/settingsPageViewModel.ts +++ b/src/ViewModel/Pages/settingsPageViewModel.ts @@ -5,8 +5,6 @@ import { Colors } from "../../colors"; import CoreViewModel, { Context } from "../Global/coreViewModel"; export default class SettingsPageViewModel extends Context { - contextDebugDescription = "settings"; - // state primaryChannel: React.State = new React.State(""); primaryChannelInput: React.State = new React.State(""); @@ -115,7 +113,7 @@ export default class SettingsPageViewModel extends Context { public readonly coreViewModel: CoreViewModel, public readonly chatViewModel: ChatViewModel, ) { - super(); + super("settings"); this.loadListRelevantData(); diff --git a/src/ViewModel/Pages/taskContainingPageViewModel.ts b/src/ViewModel/Pages/taskContainingPageViewModel.ts index 325a7e06..bdc810aa 100644 --- a/src/ViewModel/Pages/taskContainingPageViewModel.ts +++ b/src/ViewModel/Pages/taskContainingPageViewModel.ts @@ -59,7 +59,8 @@ export default class TaskContainingPageViewModel extends Context { public readonly coreViewModel: CoreViewModel, public readonly chatViewModel: ChatViewModel, public readonly boardsAndTasksModel: BoardsAndTasksModel, + contextDebugDescription: string, ) { - super(); + super(contextDebugDescription); } } diff --git a/src/ViewModel/Pages/taskPageViewModel.ts b/src/ViewModel/Pages/taskPageViewModel.ts index b3980d28..c4ab812b 100644 --- a/src/ViewModel/Pages/taskPageViewModel.ts +++ b/src/ViewModel/Pages/taskPageViewModel.ts @@ -11,8 +11,6 @@ import { IndexManager } from "../../Model/Utility/utility"; import { CommonKeys } from "../../View/keystrokes"; export default class TaskPageViewModel extends ContextHost { - contextDebugDescription = "task-page"; - // data readonly boardIndexManager = new IndexManager( (boardViewModel: BoardViewModel) => boardViewModel.name.value, @@ -145,6 +143,8 @@ export default class TaskPageViewModel extends ContextHost { // load loadData = (): void => { + console.log("LOADING TASK PAGE DATA"); + this.closeContext(); this.boardViewModels.clear(); const boardIds: string[] = this.boardsAndTasksModel.listBoardIds(); @@ -166,7 +166,7 @@ export default class TaskPageViewModel extends ContextHost { public readonly chatViewModel: ChatViewModel, public readonly boardsAndTasksModel: BoardsAndTasksModel, ) { - super(); + super("task-page"); this.chatViewModel = chatViewModel; @@ -174,17 +174,20 @@ export default class TaskPageViewModel extends ContextHost { this.chatViewModel.registerContext(ChatPageTypes.Tasks, this); this.selectedBoardId.subscribeSilent(this.updateContexts); - this.loadData(); - // handlers boardsAndTasksModel.boardHandlerManager.addHandler( (boardInfoFileContent: BoardInfoFileContent) => { this.showBoardInList(boardInfoFileContent); this.updateBoardIndices(); - this.updateContexts(); }, ); + this.chatViewModel.currentContext.subscribeSilent((context) => { + if (!this.isOpen) return; + if (context != this) return; + this.openLastUsedBoard(); + }); + // keystrokes this.registerKeyStroke(CommonKeys.Options, this.toggleBoardList); } diff --git a/src/ViewModel/Pages/taskViewModel.ts b/src/ViewModel/Pages/taskViewModel.ts index 302f3539..25527f1d 100644 --- a/src/ViewModel/Pages/taskViewModel.ts +++ b/src/ViewModel/Pages/taskViewModel.ts @@ -13,8 +13,6 @@ import { v4 } from "uuid"; import { CommonKeys } from "../../View/keystrokes"; export default class TaskViewModel extends Context { - contextDebugDescription = "task"; - // util get sortingString(): string { const splitDate: string[] = this.date.value.split("-"); @@ -87,7 +85,6 @@ export default class TaskViewModel extends Context { // view open = (): void => { - console.log(this); this.coreViewModel.context = this; this.containingModel.selectTask(this); }; @@ -219,7 +216,7 @@ export default class TaskViewModel extends Context { public readonly containingModel: TaskContainingPageViewModel, public task: TaskFileContent, ) { - super(); + super("task"); // load this.loadAllData();