fix board context management, cleanup

This commit is contained in:
marlon-erler
2026-04-13 19:45:52 +00:00
parent f16059f91a
commit c2da7f4c9b
19 changed files with 63 additions and 89 deletions
BIN
View File
Binary file not shown.
+34 -41
View File
@@ -1,9 +1,10 @@
(() => { (() => {
// ../../bloatless-react/index.ts // node_modules/bloatless-react/index.ts
var State = class { var State = class {
_value;
_bindings = /* @__PURE__ */ new Set();
// init // init
constructor(initialValue) { constructor(initialValue) {
this._bindings = /* @__PURE__ */ new Set();
this._value = initialValue; this._value = initialValue;
} }
// value // value
@@ -31,11 +32,11 @@
} }
}; };
var ListState = class extends State { var ListState = class extends State {
additionHandlers = /* @__PURE__ */ new Set();
removalHandlers = /* @__PURE__ */ new Map();
// init // init
constructor(initialItems) { constructor(initialItems) {
super(new Set(initialItems)); super(new Set(initialItems));
this.additionHandlers = /* @__PURE__ */ new Set();
this.removalHandlers = /* @__PURE__ */ new Map();
} }
// list // list
add(...items) { add(...items) {
@@ -75,11 +76,11 @@
} }
}; };
var MapState = class extends State { var MapState = class extends State {
additionHandlers = /* @__PURE__ */ new Set();
removalHandlers = /* @__PURE__ */ new Map();
// init // init
constructor(initialItems) { constructor(initialItems) {
super(new Map(initialItems)); super(new Map(initialItems));
this.additionHandlers = /* @__PURE__ */ new Set();
this.removalHandlers = /* @__PURE__ */ new Map();
} }
// list // list
set(key, item) { set(key, item) {
@@ -120,7 +121,7 @@
function createProxyState(statesToSubscibe, fn) { function createProxyState(statesToSubscibe, fn) {
const proxyState = new State(fn()); const proxyState = new State(fn());
statesToSubscibe.forEach( statesToSubscibe.forEach(
(state) => state.subscribe(() => proxyState.value = fn()) (state) => state.subscribeSilent(() => proxyState.value = fn())
); );
return proxyState; return proxyState;
} }
@@ -2254,7 +2255,7 @@
this.connectionModel = connectionModel2; this.connectionModel = connectionModel2;
this.chatListModel = chatListModel2; this.chatListModel = chatListModel2;
this.fileTransferModel = fileTransferModel2; this.fileTransferModel = fileTransferModel2;
this.BUILD = "Build 26.04.13.B"; this.BUILD = "Build 26.04.13.C";
// CONTEXT // CONTEXT
this.contextStack = /* @__PURE__ */ new Map(); this.contextStack = /* @__PURE__ */ new Map();
this.logContexts = () => { this.logContexts = () => {
@@ -2314,7 +2315,8 @@
} }
}; };
var Context = class { var Context = class {
constructor() { constructor(contextDebugDescription) {
this.contextDebugDescription = contextDebugDescription;
this.contextId = v4_default(); this.contextId = v4_default();
this.keystrokes = /* @__PURE__ */ new Map(); this.keystrokes = /* @__PURE__ */ new Map();
this.handleKeystroke = (e) => { this.handleKeystroke = (e) => {
@@ -2393,13 +2395,12 @@
var TaskViewModel = class extends Context { var TaskViewModel = class extends Context {
// init // init
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, containingModel, task) { constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, containingModel, task) {
super(); super("task");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.containingModel = containingModel; this.containingModel = containingModel;
this.task = task; this.task = task;
this.contextDebugDescription = "task";
// paths // paths
this.getFilePath = () => { this.getFilePath = () => {
return this.boardsAndTasksModel.getTaskFilePath(this.task.fileId); return this.boardsAndTasksModel.getTaskFilePath(this.task.fileId);
@@ -2565,8 +2566,8 @@
// src/ViewModel/Pages/taskContainingPageViewModel.ts // src/ViewModel/Pages/taskContainingPageViewModel.ts
var TaskContainingPageViewModel = class extends Context { var TaskContainingPageViewModel = class extends Context {
// init // init
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel) { constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, contextDebugDescription) {
super(); super(contextDebugDescription);
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
@@ -2614,12 +2615,11 @@
var CalendarPageViewModel = class extends TaskContainingPageViewModel { var CalendarPageViewModel = class extends TaskContainingPageViewModel {
// init // init
constructor(coreViewModel2, chatViewModel, calendarModel, boardsAndTasksModel) { constructor(coreViewModel2, chatViewModel, calendarModel, boardsAndTasksModel) {
super(coreViewModel2, chatViewModel, boardsAndTasksModel); super(coreViewModel2, chatViewModel, boardsAndTasksModel, "calendar");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.calendarModel = calendarModel; this.calendarModel = calendarModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.contextDebugDescription = "calendar";
// paths // paths
this.getBasePath = () => { this.getBasePath = () => {
return [...this.calendarModel.getViewPath()]; return [...this.calendarModel.getViewPath()];
@@ -2960,10 +2960,9 @@
var MessagePageViewModel = class extends Context { var MessagePageViewModel = class extends Context {
// init // init
constructor(coreViewModel2, chatViewModel) { constructor(coreViewModel2, chatViewModel) {
super(); super("message-page");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.contextDebugDescription = "message-page";
// state // state
this.chatMessageViewModels = new MapState(); this.chatMessageViewModels = new MapState();
this.filteredMessageViewModels = new ListState(); this.filteredMessageViewModels = new ListState();
@@ -3070,10 +3069,9 @@
var SettingsPageViewModel = class extends Context { var SettingsPageViewModel = class extends Context {
// init // init
constructor(coreViewModel2, chatViewModel) { constructor(coreViewModel2, chatViewModel) {
super(); super("settings");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.contextDebugDescription = "settings";
// state // state
this.primaryChannel = new State(""); this.primaryChannel = new State("");
this.primaryChannelInput = new State(""); this.primaryChannelInput = new State("");
@@ -3164,13 +3162,12 @@
var BoardViewModel = class extends TaskContainingPageViewModel { var BoardViewModel = class extends TaskContainingPageViewModel {
// init // init
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, taskPageViewModel, boardInfo) { constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, taskPageViewModel, boardInfo) {
super(coreViewModel2, chatViewModel, boardsAndTasksModel); super(coreViewModel2, chatViewModel, boardsAndTasksModel, "board");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
this.contextDebugDescription = "board";
// state // state
this.name = new State(""); this.name = new State("");
this.color = new State("standard" /* Standard */); this.color = new State("standard" /* Standard */);
@@ -3396,11 +3393,10 @@
var TaskPageViewModel = class extends ContextHost { var TaskPageViewModel = class extends ContextHost {
// init // init
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel) { constructor(coreViewModel2, chatViewModel, boardsAndTasksModel) {
super(); super("task-page");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.contextDebugDescription = "task-page";
// data // data
this.boardIndexManager = new IndexManager( this.boardIndexManager = new IndexManager(
(boardViewModel) => boardViewModel.name.value (boardViewModel) => boardViewModel.name.value
@@ -3496,6 +3492,8 @@
}; };
// load // load
this.loadData = () => { this.loadData = () => {
console.log("LOADING TASK PAGE DATA");
this.closeContext();
this.boardViewModels.clear(); this.boardViewModels.clear();
const boardIds = this.boardsAndTasksModel.listBoardIds(); const boardIds = this.boardsAndTasksModel.listBoardIds();
for (const boardId of boardIds) { for (const boardId of boardIds) {
@@ -3509,14 +3507,17 @@
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
this.chatViewModel.registerContext("tasks" /* Tasks */, this); this.chatViewModel.registerContext("tasks" /* Tasks */, this);
this.selectedBoardId.subscribeSilent(this.updateContexts); this.selectedBoardId.subscribeSilent(this.updateContexts);
this.loadData();
boardsAndTasksModel.boardHandlerManager.addHandler( boardsAndTasksModel.boardHandlerManager.addHandler(
(boardInfoFileContent) => { (boardInfoFileContent) => {
this.showBoardInList(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
this.updateBoardIndices(); this.updateBoardIndices();
this.updateContexts();
} }
); );
this.chatViewModel.currentContext.subscribeSilent((context) => {
if (!this.isOpen) return;
if (context != this) return;
this.openLastUsedBoard();
});
this.registerKeyStroke("." /* Options */, this.toggleBoardList); this.registerKeyStroke("." /* Options */, this.toggleBoardList);
} }
// context // context
@@ -3532,14 +3533,13 @@
var ChatViewModel6 = class extends ContextHost { var ChatViewModel6 = class extends ContextHost {
// init // init
constructor(coreViewModel2, chatModel, settingsViewModel2, notificationViewModel, connectionViewModel2, chatListViewModel2) { constructor(coreViewModel2, chatModel, settingsViewModel2, notificationViewModel, connectionViewModel2, chatListViewModel2) {
super(); super("chat");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.chatModel = chatModel; this.chatModel = chatModel;
this.settingsViewModel = settingsViewModel2; this.settingsViewModel = settingsViewModel2;
this.notificationViewModel = notificationViewModel; this.notificationViewModel = notificationViewModel;
this.connectionViewModel = connectionViewModel2; this.connectionViewModel = connectionViewModel2;
this.chatListViewModel = chatListViewModel2; this.chatListViewModel = chatListViewModel2;
this.contextDebugDescription = "chat";
// state // state
this.displayedColor = new State("standard" /* Standard */); this.displayedColor = new State("standard" /* Standard */);
this.selectedPage = new State( this.selectedPage = new State(
@@ -3562,8 +3562,6 @@
this.closeContext(); this.closeContext();
this.selectedPage.value = page; this.selectedPage.value = page;
}; };
this.closeSubPages = () => {
};
this.setColor = (color) => { this.setColor = (color) => {
this.setDisplayedColor(color); this.setDisplayedColor(color);
this.chatModel.setColor(color); this.chatModel.setColor(color);
@@ -3586,7 +3584,7 @@
); );
const lastUsedPage = this.coreViewModel.storageModel.read(path); const lastUsedPage = this.coreViewModel.storageModel.read(path);
if (lastUsedPage != null) { if (lastUsedPage != null) {
this.selectedPage.value = lastUsedPage; this.openPage(lastUsedPage);
} }
this.selectedPage.subscribeSilent((newPage) => { this.selectedPage.subscribeSilent((newPage) => {
this.coreViewModel.storageModel.write(path, newPage); this.coreViewModel.storageModel.write(path, newPage);
@@ -3714,7 +3712,7 @@
(chat2) => chat2.chatModel.info.primaryChannel == notification.chat (chat2) => chat2.chatModel.info.primaryChannel == notification.chat
); );
chat.open(); chat.open();
chat.selectedPage.value = "messages" /* Messages */; chat.openPage("messages" /* Messages */);
}; };
// loop // loop
this.loop = () => { this.loop = () => {
@@ -4288,7 +4286,7 @@
// src/View/Components/chatViewToggleButton.tsx // src/View/Components/chatViewToggleButton.tsx
function ChatViewToggleButton(label, icon, page, chatViewModel) { function ChatViewToggleButton(label, icon, page, chatViewModel) {
function select() { function select() {
chatViewModel.selectedPage.value = page; chatViewModel.openPage(page);
} }
const isSelected = createProxyState( const isSelected = createProxyState(
[chatViewModel.selectedPage], [chatViewModel.selectedPage],
@@ -5419,7 +5417,6 @@
const mainContent = createProxyState( const mainContent = createProxyState(
[chatViewModel.selectedPage], [chatViewModel.selectedPage],
() => { () => {
chatViewModel.closeSubPages();
switch (chatViewModel.selectedPage.value) { switch (chatViewModel.selectedPage.value) {
case "settings" /* Settings */: { case "settings" /* Settings */: {
return SettingsPage( return SettingsPage(
@@ -5974,9 +5971,8 @@
var FileTransferViewModel = class extends Context { var FileTransferViewModel = class extends Context {
// init // init
constructor(coreViewModel2) { constructor(coreViewModel2) {
super(); super("file-transfer");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.contextDebugDescription = "transfer";
// state // state
this.presentedModal = new State(void 0); this.presentedModal = new State(void 0);
this.generalFileOptions = new ListState(); this.generalFileOptions = new ListState();
@@ -6691,9 +6687,8 @@
var SettingsViewModel = class _SettingsViewModel extends Context { var SettingsViewModel = class _SettingsViewModel extends Context {
// init // init
constructor(coreViewModel2) { constructor(coreViewModel2) {
super(); super("settings");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.contextDebugDescription = "settings";
// state // state
this.username = new State(""); this.username = new State("");
this.usernameInput = new State(""); this.usernameInput = new State("");
@@ -6909,9 +6904,8 @@
var StorageViewModel = class extends Context { var StorageViewModel = class extends Context {
// init // init
constructor(coreViewModel2) { constructor(coreViewModel2) {
super(); super("storage");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.contextDebugDescription = "storage";
// state // state
this.isShowingStorageModal = new State(false); this.isShowingStorageModal = new State(false);
this.selectedPath = new State( this.selectedPath = new State(
@@ -7318,13 +7312,12 @@
// src/ViewModel/Pages/homeViewModel.ts // src/ViewModel/Pages/homeViewModel.ts
var HomeViewModel = class extends Context { var HomeViewModel = class extends Context {
constructor(coreViewModel2, settingsViewModel2, fileTransferViewModel2, storageViewModel2, connectionViewModel2) { constructor(coreViewModel2, settingsViewModel2, fileTransferViewModel2, storageViewModel2, connectionViewModel2) {
super(); super("home");
this.coreViewModel = coreViewModel2; this.coreViewModel = coreViewModel2;
this.settingsViewModel = settingsViewModel2; this.settingsViewModel = settingsViewModel2;
this.fileTransferViewModel = fileTransferViewModel2; this.fileTransferViewModel = fileTransferViewModel2;
this.storageViewModel = storageViewModel2; this.storageViewModel = storageViewModel2;
this.connectionViewModel = connectionViewModel2; this.connectionViewModel = connectionViewModel2;
this.contextDebugDescription = "home";
this.coreViewModel.context = this; this.coreViewModel.context = this;
this.registerKeyStroke( this.registerKeyStroke(
"," /* Settings */, "," /* Settings */,
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"dependencies": { "dependencies": {
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"bloatless-react": "^1.3.11", "bloatless-react": "1.3.14",
"esbuild": "^0.23.0", "esbuild": "^0.23.1",
"udn-frontend": "^1.0.9", "udn-frontend": "^1.0.9",
"uuid": "^10.0.0" "uuid": "^10.0.0"
}, },
+1 -1
View File
@@ -13,7 +13,7 @@ export function ChatViewToggleButton(
chatViewModel: ChatViewModel, chatViewModel: ChatViewModel,
) { ) {
function select() { function select() {
chatViewModel.selectedPage.value = page; chatViewModel.openPage(page);
} }
const isSelected = React.createProxyState( const isSelected = React.createProxyState(
-2
View File
@@ -18,8 +18,6 @@ export function ChatPage(
const mainContent = React.createProxyState( const mainContent = React.createProxyState(
[chatViewModel.selectedPage], [chatViewModel.selectedPage],
() => { () => {
chatViewModel.closeSubPages();
switch (chatViewModel.selectedPage.value) { switch (chatViewModel.selectedPage.value) {
case ChatPageTypes.Settings: { case ChatPageTypes.Settings: {
return SettingsPage( return SettingsPage(
+3 -6
View File
@@ -26,8 +26,6 @@ import { v4 } from "uuid";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class ChatViewModel extends ContextHost<ChatPageTypes> { export default class ChatViewModel extends ContextHost<ChatPageTypes> {
contextDebugDescription = "chat";
calendarViewModel: CalendarPageViewModel; calendarViewModel: CalendarPageViewModel;
taskPageViewModel: TaskPageViewModel; taskPageViewModel: TaskPageViewModel;
messagePageViewModel: MessagePageViewModel; messagePageViewModel: MessagePageViewModel;
@@ -58,6 +56,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
open = (): void => { open = (): void => {
this.coreViewModel.context = this; this.coreViewModel.context = this;
this.chatListViewModel.openChat(this); this.chatListViewModel.openChat(this);
//this.selectedPage.callSubscriptions();
}; };
close = (): void => { close = (): void => {
@@ -70,8 +69,6 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
this.selectedPage.value = page; this.selectedPage.value = page;
}; };
closeSubPages = (): void => {};
setColor = (color: Colors): void => { setColor = (color: Colors): void => {
this.setDisplayedColor(color); this.setDisplayedColor(color);
this.chatModel.setColor(color); this.chatModel.setColor(color);
@@ -100,7 +97,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
const lastUsedPage: string | null = const lastUsedPage: string | null =
this.coreViewModel.storageModel.read(path); this.coreViewModel.storageModel.read(path);
if (lastUsedPage != null) { if (lastUsedPage != null) {
this.selectedPage.value = lastUsedPage as any; this.openPage(lastUsedPage as ChatPageTypes);
} }
this.selectedPage.subscribeSilent((newPage) => { this.selectedPage.subscribeSilent((newPage) => {
@@ -152,7 +149,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
public readonly connectionViewModel: ConnectionViewModel, public readonly connectionViewModel: ConnectionViewModel,
public readonly chatListViewModel: ChatListViewModel, public readonly chatListViewModel: ChatListViewModel,
) { ) {
super(); super("chat");
// page viewModels // page viewModels
this.calendarViewModel = new CalendarPageViewModel( this.calendarViewModel = new CalendarPageViewModel(
+2 -1
View File
@@ -94,7 +94,6 @@ export default class CoreViewModel {
export class Context { export class Context {
contextId = v4(); contextId = v4();
contextDebugDescription: string;
keystrokes = new Map<string, () => void>(); keystrokes = new Map<string, () => void>();
handleKeystroke = (e: KeyboardEvent): boolean => { handleKeystroke = (e: KeyboardEvent): boolean => {
@@ -112,6 +111,8 @@ export class Context {
registerKeyStroke = (key: string, fn: () => void): void => { registerKeyStroke = (key: string, fn: () => void): void => {
this.keystrokes.set(key, fn); this.keystrokes.set(key, fn);
}; };
constructor(public contextDebugDescription: string) {}
} }
export class ContextHost<T> extends Context { export class ContextHost<T> extends Context {
@@ -13,8 +13,6 @@ import CoreViewModel, { Context } from "./coreViewModel";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class FileTransferViewModel extends Context { export default class FileTransferViewModel extends Context {
contextDebugDescription = "transfer";
// state // state
presentedModal: React.State<FileTransferModals | undefined> = presentedModal: React.State<FileTransferModals | undefined> =
new React.State<any>(undefined); new React.State<any>(undefined);
@@ -173,7 +171,7 @@ export default class FileTransferViewModel extends Context {
// init // init
constructor(public readonly coreViewModel: CoreViewModel) { constructor(public readonly coreViewModel: CoreViewModel) {
super(); super("file-transfer");
this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler( this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler(
this.handleReceivedFile, this.handleReceivedFile,
@@ -42,7 +42,7 @@ export default class NotificationViewModel {
(chat) => chat.chatModel.info.primaryChannel == notification.chat, (chat) => chat.chatModel.info.primaryChannel == notification.chat,
); );
chat.open(); chat.open();
chat.selectedPage.value = ChatPageTypes.Messages; chat.openPage(ChatPageTypes.Messages);
}; };
// loop // loop
+1 -3
View File
@@ -5,8 +5,6 @@ import { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class SettingsViewModel extends Context { export default class SettingsViewModel extends Context {
contextDebugDescription = "settings";
// state // state
username: React.State<string> = new React.State(""); username: React.State<string> = new React.State("");
usernameInput: React.State<string> = new React.State(""); usernameInput: React.State<string> = new React.State("");
@@ -73,7 +71,7 @@ export default class SettingsViewModel extends Context {
// init // init
constructor(public readonly coreViewModel: CoreViewModel) { constructor(public readonly coreViewModel: CoreViewModel) {
super(); super("settings");
this.username.value = coreViewModel.settingsModel.username; this.username.value = coreViewModel.settingsModel.username;
this.usernameInput.value = coreViewModel.settingsModel.username; this.usernameInput.value = coreViewModel.settingsModel.username;
+1 -3
View File
@@ -8,8 +8,6 @@ import CoreViewModel, { Context } from "./coreViewModel";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class StorageViewModel extends Context { export default class StorageViewModel extends Context {
contextDebugDescription = "storage";
// state // state
isShowingStorageModal: React.State<boolean> = new React.State(false); isShowingStorageModal: React.State<boolean> = new React.State(false);
selectedPath: React.State<string> = new React.State( selectedPath: React.State<string> = new React.State(
@@ -67,7 +65,7 @@ export default class StorageViewModel extends Context {
// init // init
constructor(public readonly coreViewModel: CoreViewModel) { constructor(public readonly coreViewModel: CoreViewModel) {
super(); super("storage");
this.selectedFileName = React.createProxyState( this.selectedFileName = React.createProxyState(
[this.selectedPath], [this.selectedPath],
+1 -3
View File
@@ -16,8 +16,6 @@ import TaskViewModel from "./taskViewModel";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class BoardViewModel extends TaskContainingPageViewModel { export default class BoardViewModel extends TaskContainingPageViewModel {
contextDebugDescription = "board";
// state // state
name: React.State<string> = new React.State(""); name: React.State<string> = new React.State("");
color: React.State<Colors> = new React.State<any>(Colors.Standard); color: React.State<Colors> = new React.State<any>(Colors.Standard);
@@ -255,7 +253,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
public readonly taskPageViewModel: TaskPageViewModel, public readonly taskPageViewModel: TaskPageViewModel,
public readonly boardInfo: BoardInfoFileContent, public readonly boardInfo: BoardInfoFileContent,
) { ) {
super(coreViewModel, chatViewModel, boardsAndTasksModel); super(coreViewModel, chatViewModel, boardsAndTasksModel, "board");
// load // load
this.loadListRelevantData(); this.loadListRelevantData();
+1 -3
View File
@@ -14,8 +14,6 @@ import { CommonKeys } from "../../View/keystrokes";
export const CALENDAR_EVENT_BOARD_ID = "events"; export const CALENDAR_EVENT_BOARD_ID = "events";
export default class CalendarPageViewModel extends TaskContainingPageViewModel { export default class CalendarPageViewModel extends TaskContainingPageViewModel {
contextDebugDescription = "calendar";
// data // data
get monthString(): string { get monthString(): string {
return CalendarModel.getMonthString( return CalendarModel.getMonthString(
@@ -190,7 +188,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
public readonly calendarModel: CalendarModel, public readonly calendarModel: CalendarModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel, public readonly boardsAndTasksModel: BoardsAndTasksModel,
) { ) {
super(coreViewModel, chatViewModel, boardsAndTasksModel); super(coreViewModel, chatViewModel, boardsAndTasksModel, "calendar");
this.calendarModel = calendarModel; this.calendarModel = calendarModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
+1 -3
View File
@@ -6,8 +6,6 @@ import SettingsViewModel from "../Global/settingsViewModel";
import StorageViewModel from "../Global/storageViewModel"; import StorageViewModel from "../Global/storageViewModel";
export default class HomeViewModel extends Context { export default class HomeViewModel extends Context {
contextDebugDescription = "home";
constructor( constructor(
public readonly coreViewModel: CoreViewModel, public readonly coreViewModel: CoreViewModel,
public readonly settingsViewModel: SettingsViewModel, public readonly settingsViewModel: SettingsViewModel,
@@ -15,7 +13,7 @@ export default class HomeViewModel extends Context {
public readonly storageViewModel: StorageViewModel, public readonly storageViewModel: StorageViewModel,
public readonly connectionViewModel: ConnectionViewModel, public readonly connectionViewModel: ConnectionViewModel,
) { ) {
super(); super("home");
this.coreViewModel.context = this; this.coreViewModel.context = this;
+1 -3
View File
@@ -13,8 +13,6 @@ import { v4 } from "uuid";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class MessagePageViewModel extends Context { export default class MessagePageViewModel extends Context {
contextDebugDescription = "message-page";
// state // state
chatMessageViewModels: React.MapState<ChatMessageViewModel> = chatMessageViewModels: React.MapState<ChatMessageViewModel> =
new React.MapState(); new React.MapState();
@@ -130,7 +128,7 @@ export default class MessagePageViewModel extends Context {
public readonly coreViewModel: CoreViewModel, public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel, public readonly chatViewModel: ChatViewModel,
) { ) {
super(); super("message-page");
// states // states
this.cannotSendMessage = React.createProxyState( this.cannotSendMessage = React.createProxyState(
+1 -3
View File
@@ -5,8 +5,6 @@ import { Colors } from "../../colors";
import CoreViewModel, { Context } from "../Global/coreViewModel"; import CoreViewModel, { Context } from "../Global/coreViewModel";
export default class SettingsPageViewModel extends Context { export default class SettingsPageViewModel extends Context {
contextDebugDescription = "settings";
// state // state
primaryChannel: React.State<string> = new React.State(""); primaryChannel: React.State<string> = new React.State("");
primaryChannelInput: React.State<string> = new React.State(""); primaryChannelInput: React.State<string> = new React.State("");
@@ -115,7 +113,7 @@ export default class SettingsPageViewModel extends Context {
public readonly coreViewModel: CoreViewModel, public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel, public readonly chatViewModel: ChatViewModel,
) { ) {
super(); super("settings");
this.loadListRelevantData(); this.loadListRelevantData();
@@ -59,7 +59,8 @@ export default class TaskContainingPageViewModel extends Context {
public readonly coreViewModel: CoreViewModel, public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel, public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel, public readonly boardsAndTasksModel: BoardsAndTasksModel,
contextDebugDescription: string,
) { ) {
super(); super(contextDebugDescription);
} }
} }
+9 -6
View File
@@ -11,8 +11,6 @@ import { IndexManager } from "../../Model/Utility/utility";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class TaskPageViewModel extends ContextHost<string> { export default class TaskPageViewModel extends ContextHost<string> {
contextDebugDescription = "task-page";
// data // data
readonly boardIndexManager = new IndexManager<BoardViewModel>( readonly boardIndexManager = new IndexManager<BoardViewModel>(
(boardViewModel: BoardViewModel) => boardViewModel.name.value, (boardViewModel: BoardViewModel) => boardViewModel.name.value,
@@ -145,6 +143,8 @@ export default class TaskPageViewModel extends ContextHost<string> {
// load // load
loadData = (): void => { loadData = (): void => {
console.log("LOADING TASK PAGE DATA");
this.closeContext();
this.boardViewModels.clear(); this.boardViewModels.clear();
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds(); const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
@@ -166,7 +166,7 @@ export default class TaskPageViewModel extends ContextHost<string> {
public readonly chatViewModel: ChatViewModel, public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel, public readonly boardsAndTasksModel: BoardsAndTasksModel,
) { ) {
super(); super("task-page");
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
@@ -174,17 +174,20 @@ export default class TaskPageViewModel extends ContextHost<string> {
this.chatViewModel.registerContext(ChatPageTypes.Tasks, this); this.chatViewModel.registerContext(ChatPageTypes.Tasks, this);
this.selectedBoardId.subscribeSilent(this.updateContexts); this.selectedBoardId.subscribeSilent(this.updateContexts);
this.loadData();
// handlers // handlers
boardsAndTasksModel.boardHandlerManager.addHandler( boardsAndTasksModel.boardHandlerManager.addHandler(
(boardInfoFileContent: BoardInfoFileContent) => { (boardInfoFileContent: BoardInfoFileContent) => {
this.showBoardInList(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
this.updateBoardIndices(); this.updateBoardIndices();
this.updateContexts();
}, },
); );
this.chatViewModel.currentContext.subscribeSilent((context) => {
if (!this.isOpen) return;
if (context != this) return;
this.openLastUsedBoard();
});
// keystrokes // keystrokes
this.registerKeyStroke(CommonKeys.Options, this.toggleBoardList); this.registerKeyStroke(CommonKeys.Options, this.toggleBoardList);
} }
+1 -4
View File
@@ -13,8 +13,6 @@ import { v4 } from "uuid";
import { CommonKeys } from "../../View/keystrokes"; import { CommonKeys } from "../../View/keystrokes";
export default class TaskViewModel extends Context { export default class TaskViewModel extends Context {
contextDebugDescription = "task";
// util // util
get sortingString(): string { get sortingString(): string {
const splitDate: string[] = this.date.value.split("-"); const splitDate: string[] = this.date.value.split("-");
@@ -87,7 +85,6 @@ export default class TaskViewModel extends Context {
// view // view
open = (): void => { open = (): void => {
console.log(this);
this.coreViewModel.context = this; this.coreViewModel.context = this;
this.containingModel.selectTask(this); this.containingModel.selectTask(this);
}; };
@@ -219,7 +216,7 @@ export default class TaskViewModel extends Context {
public readonly containingModel: TaskContainingPageViewModel, public readonly containingModel: TaskContainingPageViewModel,
public task: TaskFileContent, public task: TaskFileContent,
) { ) {
super(); super("task");
// load // load
this.loadAllData(); this.loadAllData();