fix board context management, cleanup
This commit is contained in:
Vendored
+34
-41
@@ -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 */,
|
||||
|
||||
+2
-2
@@ -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"
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ export function ChatViewToggleButton(
|
||||
chatViewModel: ChatViewModel,
|
||||
) {
|
||||
function select() {
|
||||
chatViewModel.selectedPage.value = page;
|
||||
chatViewModel.openPage(page);
|
||||
}
|
||||
|
||||
const isSelected = React.createProxyState(
|
||||
|
||||
@@ -18,8 +18,6 @@ export function ChatPage(
|
||||
const mainContent = React.createProxyState(
|
||||
[chatViewModel.selectedPage],
|
||||
() => {
|
||||
chatViewModel.closeSubPages();
|
||||
|
||||
switch (chatViewModel.selectedPage.value) {
|
||||
case ChatPageTypes.Settings: {
|
||||
return SettingsPage(
|
||||
|
||||
@@ -26,8 +26,6 @@ import { v4 } from "uuid";
|
||||
import { CommonKeys } from "../../View/keystrokes";
|
||||
|
||||
export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
||||
contextDebugDescription = "chat";
|
||||
|
||||
calendarViewModel: CalendarPageViewModel;
|
||||
taskPageViewModel: TaskPageViewModel;
|
||||
messagePageViewModel: MessagePageViewModel;
|
||||
@@ -58,6 +56,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
||||
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<ChatPageTypes> {
|
||||
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<ChatPageTypes> {
|
||||
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<ChatPageTypes> {
|
||||
public readonly connectionViewModel: ConnectionViewModel,
|
||||
public readonly chatListViewModel: ChatListViewModel,
|
||||
) {
|
||||
super();
|
||||
super("chat");
|
||||
|
||||
// page viewModels
|
||||
this.calendarViewModel = new CalendarPageViewModel(
|
||||
|
||||
@@ -94,7 +94,6 @@ export default class CoreViewModel {
|
||||
|
||||
export class Context {
|
||||
contextId = v4();
|
||||
contextDebugDescription: string;
|
||||
keystrokes = new Map<string, () => 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<T> extends Context {
|
||||
|
||||
@@ -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<FileTransferModals | undefined> =
|
||||
new React.State<any>(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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<string> = new React.State("");
|
||||
usernameInput: React.State<string> = 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;
|
||||
|
||||
@@ -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<boolean> = new React.State(false);
|
||||
selectedPath: React.State<string> = 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],
|
||||
|
||||
@@ -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<string> = new React.State("");
|
||||
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 boardInfo: BoardInfoFileContent,
|
||||
) {
|
||||
super(coreViewModel, chatViewModel, boardsAndTasksModel);
|
||||
super(coreViewModel, chatViewModel, boardsAndTasksModel, "board");
|
||||
|
||||
// load
|
||||
this.loadListRelevantData();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<ChatMessageViewModel> =
|
||||
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(
|
||||
|
||||
@@ -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<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 chatViewModel: ChatViewModel,
|
||||
) {
|
||||
super();
|
||||
super("settings");
|
||||
|
||||
this.loadListRelevantData();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ import { IndexManager } from "../../Model/Utility/utility";
|
||||
import { CommonKeys } from "../../View/keystrokes";
|
||||
|
||||
export default class TaskPageViewModel extends ContextHost<string> {
|
||||
contextDebugDescription = "task-page";
|
||||
|
||||
// data
|
||||
readonly boardIndexManager = new IndexManager<BoardViewModel>(
|
||||
(boardViewModel: BoardViewModel) => boardViewModel.name.value,
|
||||
@@ -145,6 +143,8 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
||||
|
||||
// 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<string> {
|
||||
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<string> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user