fix bug where board viewmodels where re-created
This commit is contained in:
Vendored
+42
-25
@@ -1616,7 +1616,10 @@
|
|||||||
this.settingsModel = settingsModel2;
|
this.settingsModel = settingsModel2;
|
||||||
this.connectionModel = connectionModel2;
|
this.connectionModel = connectionModel2;
|
||||||
this.loadChats();
|
this.loadChats();
|
||||||
connectionModel2.messageHandlerManager.setHandler("chat-list", this.messageHandler);
|
connectionModel2.messageHandlerManager.setHandler(
|
||||||
|
"chat-list",
|
||||||
|
this.messageHandler
|
||||||
|
);
|
||||||
connectionModel2.messageSentHandlerManager.setHandler(
|
connectionModel2.messageSentHandlerManager.setHandler(
|
||||||
"chat-list",
|
"chat-list",
|
||||||
this.messageSentHandler
|
this.messageSentHandler
|
||||||
@@ -2254,7 +2257,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.E";
|
this.BUILD = "Build 26.04.14.A";
|
||||||
// CONTEXT
|
// CONTEXT
|
||||||
this.contextStack = /* @__PURE__ */ new Map();
|
this.contextStack = /* @__PURE__ */ new Map();
|
||||||
this.closeContext = (contextId) => {
|
this.closeContext = (contextId) => {
|
||||||
@@ -2381,12 +2384,12 @@
|
|||||||
// src/ViewModel/Pages/taskViewModel.ts
|
// src/ViewModel/Pages/taskViewModel.ts
|
||||||
var TaskViewModel = class extends Context {
|
var TaskViewModel = class extends Context {
|
||||||
// init
|
// init
|
||||||
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, containingModel, task) {
|
constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, containingViewModel, task) {
|
||||||
super("task");
|
super("task");
|
||||||
this.coreViewModel = coreViewModel2;
|
this.coreViewModel = coreViewModel2;
|
||||||
this.chatViewModel = chatViewModel;
|
this.chatViewModel = chatViewModel;
|
||||||
this.boardsAndTasksModel = boardsAndTasksModel;
|
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||||
this.containingModel = containingModel;
|
this.containingViewModel = containingViewModel;
|
||||||
this.task = task;
|
this.task = task;
|
||||||
// paths
|
// paths
|
||||||
this.getFilePath = () => {
|
this.getFilePath = () => {
|
||||||
@@ -2425,11 +2428,11 @@
|
|||||||
// view
|
// view
|
||||||
this.open = () => {
|
this.open = () => {
|
||||||
this.coreViewModel.context = this;
|
this.coreViewModel.context = this;
|
||||||
this.containingModel.selectTask(this);
|
this.containingViewModel.selectTask(this);
|
||||||
};
|
};
|
||||||
this.close = () => {
|
this.close = () => {
|
||||||
this.coreViewModel.closeContext(this.contextId);
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.containingModel.closeTask();
|
this.containingViewModel.closeTask();
|
||||||
};
|
};
|
||||||
this.closeAndDiscard = () => {
|
this.closeAndDiscard = () => {
|
||||||
this.close();
|
this.close();
|
||||||
@@ -2440,7 +2443,7 @@
|
|||||||
this.save();
|
this.save();
|
||||||
};
|
};
|
||||||
this.updateIndex = () => {
|
this.updateIndex = () => {
|
||||||
const index = this.containingModel.taskIndexManager.getIndex(this);
|
const index = this.containingViewModel.taskIndexManager.getIndex(this);
|
||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
this.updateSuggestions = () => {
|
this.updateSuggestions = () => {
|
||||||
@@ -2470,8 +2473,8 @@
|
|||||||
newTaskFileContent.date = this.date.value;
|
newTaskFileContent.date = this.date.value;
|
||||||
newTaskFileContent.time = this.time.value;
|
newTaskFileContent.time = this.time.value;
|
||||||
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
||||||
this.containingModel.showTask(newTaskFileContent);
|
this.containingViewModel.showTask(newTaskFileContent);
|
||||||
this.containingModel.updateTaskIndices();
|
this.containingViewModel.updateTaskIndices();
|
||||||
this.updateSuggestions();
|
this.updateSuggestions();
|
||||||
};
|
};
|
||||||
this.deleteTask = () => {
|
this.deleteTask = () => {
|
||||||
@@ -2480,7 +2483,7 @@
|
|||||||
this.task.boardId,
|
this.task.boardId,
|
||||||
this.task.fileId
|
this.task.fileId
|
||||||
);
|
);
|
||||||
this.containingModel.removeTaskFromView(this.task);
|
this.containingViewModel.removeTaskFromView(this.task);
|
||||||
};
|
};
|
||||||
// load
|
// load
|
||||||
this.loadVersionIds = () => {
|
this.loadVersionIds = () => {
|
||||||
@@ -3331,6 +3334,7 @@
|
|||||||
this.loadTasks();
|
this.loadTasks();
|
||||||
this.loadSearchSuggestions();
|
this.loadSearchSuggestions();
|
||||||
};
|
};
|
||||||
|
console.log("NEW BOARD VM");
|
||||||
this.loadListRelevantData();
|
this.loadListRelevantData();
|
||||||
this.isSelected = createProxyState(
|
this.isSelected = createProxyState(
|
||||||
[this.taskPageViewModel.selectedBoardId],
|
[this.taskPageViewModel.selectedBoardId],
|
||||||
@@ -3344,6 +3348,11 @@
|
|||||||
});
|
});
|
||||||
this.selectedPage.subscribeSilent(() => {
|
this.selectedPage.subscribeSilent(() => {
|
||||||
this.storeLastUsedView();
|
this.storeLastUsedView();
|
||||||
|
console.log(
|
||||||
|
"SELECTED PAGE",
|
||||||
|
this.selectedPage.value,
|
||||||
|
this.contextId
|
||||||
|
);
|
||||||
});
|
});
|
||||||
boardsAndTasksModel.taskHandlerManager.setHandler(
|
boardsAndTasksModel.taskHandlerManager.setHandler(
|
||||||
this.boardInfo.fileId,
|
this.boardInfo.fileId,
|
||||||
@@ -3434,6 +3443,7 @@
|
|||||||
this.isShowingBoadList.value = !this.isShowingBoadList.value;
|
this.isShowingBoadList.value = !this.isShowingBoadList.value;
|
||||||
};
|
};
|
||||||
this.showBoardInList = (boardInfo) => {
|
this.showBoardInList = (boardInfo) => {
|
||||||
|
if (this.boardViewModels.value.has(boardInfo.fileId)) return;
|
||||||
const boardViewModel = new BoardViewModel(
|
const boardViewModel = new BoardViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.chatViewModel,
|
this.chatViewModel,
|
||||||
@@ -3448,8 +3458,11 @@
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
this.selectBoard = (boardViewModel) => {
|
this.selectBoard = (boardViewModel) => {
|
||||||
this.selectedBoardId.value = boardViewModel.boardInfo.fileId;
|
|
||||||
this.chatViewModel.displayedColor.value = boardViewModel.color.value;
|
this.chatViewModel.displayedColor.value = boardViewModel.color.value;
|
||||||
|
if (this.selectedBoardId.value == boardViewModel.boardInfo.fileId) {
|
||||||
|
return this.updateContexts();
|
||||||
|
}
|
||||||
|
this.selectedBoardId.value = boardViewModel.boardInfo.fileId;
|
||||||
this.storeLastUsedBoard();
|
this.storeLastUsedBoard();
|
||||||
};
|
};
|
||||||
this.closeBoard = () => {
|
this.closeBoard = () => {
|
||||||
@@ -3481,9 +3494,9 @@
|
|||||||
// load
|
// load
|
||||||
this.loadData = () => {
|
this.loadData = () => {
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
this.boardViewModels.clear();
|
|
||||||
const boardIds = this.boardsAndTasksModel.listBoardIds();
|
const boardIds = this.boardsAndTasksModel.listBoardIds();
|
||||||
for (const boardId of boardIds) {
|
for (const boardId of boardIds) {
|
||||||
|
if (this.boardViewModels.value.has(boardId)) continue;
|
||||||
const boardInfo = this.boardsAndTasksModel.getBoardInfo(boardId);
|
const boardInfo = this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||||
if (boardInfo == null) continue;
|
if (boardInfo == null) continue;
|
||||||
this.showBoardInList(boardInfo);
|
this.showBoardInList(boardInfo);
|
||||||
@@ -5197,7 +5210,6 @@
|
|||||||
if (this.trackers.has(key)) {
|
if (this.trackers.has(key)) {
|
||||||
return this.trackers.get(key);
|
return this.trackers.get(key);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
const tracker = new PageTracker();
|
const tracker = new PageTracker();
|
||||||
this.trackers.set(key, tracker);
|
this.trackers.set(key, tracker);
|
||||||
return tracker;
|
return tracker;
|
||||||
@@ -5229,9 +5241,9 @@
|
|||||||
function BoardPage(coreViewModel2, boardViewModel) {
|
function BoardPage(coreViewModel2, boardViewModel) {
|
||||||
boardViewModel.loadData();
|
boardViewModel.loadData();
|
||||||
const persistenceId = boardViewModel.boardInfo.fileId;
|
const persistenceId = boardViewModel.boardInfo.fileId;
|
||||||
const pages = ViewPersistence.boardPages.setPages(persistenceId, () => createProxyState(
|
const pages = ViewPersistence.boardPages.setPages(
|
||||||
[boardViewModel.selectedPage],
|
persistenceId,
|
||||||
() => {
|
() => createProxyState([boardViewModel.selectedPage], () => {
|
||||||
switch (boardViewModel.selectedPage.value) {
|
switch (boardViewModel.selectedPage.value) {
|
||||||
case "kanban" /* Kanban */: {
|
case "kanban" /* Kanban */: {
|
||||||
return BoardKanbanPage(coreViewModel2, boardViewModel);
|
return BoardKanbanPage(coreViewModel2, boardViewModel);
|
||||||
@@ -5252,8 +5264,8 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
));
|
);
|
||||||
const taskSettingsModal = createProxyState(
|
const taskSettingsModal = createProxyState(
|
||||||
[boardViewModel.selectedTaskViewModel],
|
[boardViewModel.selectedTaskViewModel],
|
||||||
() => {
|
() => {
|
||||||
@@ -5372,9 +5384,9 @@
|
|||||||
() => taskPageViewModel.selectedBoardId.value != void 0
|
() => taskPageViewModel.selectedBoardId.value != void 0
|
||||||
);
|
);
|
||||||
const persistenceId = taskPageViewModel.chatViewModel.chatModel.id;
|
const persistenceId = taskPageViewModel.chatViewModel.chatModel.id;
|
||||||
const pages = ViewPersistence.taskPages.setPages(persistenceId, () => createProxyState(
|
const pages = ViewPersistence.taskPages.setPages(
|
||||||
[taskPageViewModel.selectedBoardId],
|
persistenceId,
|
||||||
() => {
|
() => createProxyState([taskPageViewModel.selectedBoardId], () => {
|
||||||
const selectedBoardId = taskPageViewModel.selectedBoardId.value;
|
const selectedBoardId = taskPageViewModel.selectedBoardId.value;
|
||||||
if (selectedBoardId == void 0) {
|
if (selectedBoardId == void 0) {
|
||||||
return PlaceholderView(
|
return PlaceholderView(
|
||||||
@@ -5385,10 +5397,9 @@
|
|||||||
if (selectedBoard == void 0) {
|
if (selectedBoard == void 0) {
|
||||||
return /* @__PURE__ */ createElement("div", { class: "pane align-center justify-center" }, /* @__PURE__ */ createElement("span", { class: "secondary" }, coreViewModel2.translations.chatPage.task.boardNotFound));
|
return /* @__PURE__ */ createElement("div", { class: "pane align-center justify-center" }, /* @__PURE__ */ createElement("span", { class: "secondary" }, coreViewModel2.translations.chatPage.task.boardNotFound));
|
||||||
}
|
}
|
||||||
console.log("BOARD PAGE");
|
|
||||||
return BoardPage(coreViewModel2, selectedBoard);
|
return BoardPage(coreViewModel2, selectedBoard);
|
||||||
}
|
})
|
||||||
));
|
);
|
||||||
return /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement(
|
||||||
"div",
|
"div",
|
||||||
{
|
{
|
||||||
@@ -5536,7 +5547,13 @@
|
|||||||
"settings",
|
"settings",
|
||||||
"settings" /* Settings */,
|
"settings" /* Settings */,
|
||||||
chatViewModel
|
chatViewModel
|
||||||
))), /* @__PURE__ */ createElement("div", { id: "main", "children:set": ViewPersistence.chatPages.pages }))
|
))), /* @__PURE__ */ createElement(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
id: "main",
|
||||||
|
"children:set": ViewPersistence.chatPages.pages
|
||||||
|
}
|
||||||
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,12 @@ export default class ChatListModel {
|
|||||||
this.connectionModel = connectionModel;
|
this.connectionModel = connectionModel;
|
||||||
this.loadChats();
|
this.loadChats();
|
||||||
|
|
||||||
connectionModel.messageHandlerManager.setHandler("chat-list", this.messageHandler);
|
connectionModel.messageHandlerManager.setHandler(
|
||||||
connectionModel.messageSentHandlerManager.setHandler("chat-list",
|
"chat-list",
|
||||||
|
this.messageHandler,
|
||||||
|
);
|
||||||
|
connectionModel.messageSentHandlerManager.setHandler(
|
||||||
|
"chat-list",
|
||||||
this.messageSentHandler,
|
this.messageSentHandler,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ export default class FileTransferModel {
|
|||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
this.connectionModel = connectionModel;
|
this.connectionModel = connectionModel;
|
||||||
|
|
||||||
this.connectionModel.messageHandlerManager.setHandler("file-transfer",
|
this.connectionModel.messageHandlerManager.setHandler(
|
||||||
|
"file-transfer",
|
||||||
this.handleMessage,
|
this.handleMessage,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ export function BoardPage(
|
|||||||
|
|
||||||
// main content
|
// main content
|
||||||
const persistenceId = boardViewModel.boardInfo.fileId;
|
const persistenceId = boardViewModel.boardInfo.fileId;
|
||||||
const pages = ViewPersistence.boardPages.setPages(persistenceId, ()=>React.createProxyState(
|
const pages = ViewPersistence.boardPages.setPages(persistenceId, () =>
|
||||||
[boardViewModel.selectedPage],
|
React.createProxyState([boardViewModel.selectedPage], () => {
|
||||||
() => {
|
|
||||||
switch (boardViewModel.selectedPage.value) {
|
switch (boardViewModel.selectedPage.value) {
|
||||||
case BoardPageTypes.Kanban: {
|
case BoardPageTypes.Kanban: {
|
||||||
return BoardKanbanPage(coreViewModel, boardViewModel);
|
return BoardKanbanPage(coreViewModel, boardViewModel);
|
||||||
@@ -45,8 +44,8 @@ export function BoardPage(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
));
|
);
|
||||||
|
|
||||||
// task modal
|
// task modal
|
||||||
const taskSettingsModal = React.createProxyState(
|
const taskSettingsModal = React.createProxyState(
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ export function TaskPage(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const persistenceId = taskPageViewModel.chatViewModel.chatModel.id;
|
const persistenceId = taskPageViewModel.chatViewModel.chatModel.id;
|
||||||
const pages = ViewPersistence.taskPages.setPages(persistenceId, ()=>React.createProxyState(
|
const pages = ViewPersistence.taskPages.setPages(persistenceId, () =>
|
||||||
[taskPageViewModel.selectedBoardId],
|
React.createProxyState([taskPageViewModel.selectedBoardId], () => {
|
||||||
() => {
|
|
||||||
const selectedBoardId = taskPageViewModel.selectedBoardId.value;
|
const selectedBoardId = taskPageViewModel.selectedBoardId.value;
|
||||||
if (selectedBoardId == undefined) {
|
if (selectedBoardId == undefined) {
|
||||||
return PlaceholderView(
|
return PlaceholderView(
|
||||||
@@ -47,8 +46,8 @@ export function TaskPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return BoardPage(coreViewModel, selectedBoard);
|
return BoardPage(coreViewModel, selectedBoard);
|
||||||
},
|
}),
|
||||||
));
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ export function ChatPage(
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="main" children:set={ViewPersistence.chatPages.pages}></div>
|
<div
|
||||||
|
id="main"
|
||||||
|
children:set={ViewPersistence.chatPages.pages}
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,13 +10,16 @@ class PageTrackerMap {
|
|||||||
private register = (key: string): PageTracker => {
|
private register = (key: string): PageTracker => {
|
||||||
if (this.trackers.has(key)) {
|
if (this.trackers.has(key)) {
|
||||||
return this.trackers.get(key);
|
return this.trackers.get(key);
|
||||||
};
|
}
|
||||||
const tracker = new PageTracker();
|
const tracker = new PageTracker();
|
||||||
this.trackers.set(key, tracker);
|
this.trackers.set(key, tracker);
|
||||||
return tracker
|
return tracker;
|
||||||
}
|
};
|
||||||
|
|
||||||
setPages = (key: string, pages: () => React.State<HTMLElement>): React.State<HTMLElement | undefined> | undefined => {
|
setPages = (
|
||||||
|
key: string,
|
||||||
|
pages: () => React.State<HTMLElement>,
|
||||||
|
): React.State<HTMLElement | undefined> | undefined => {
|
||||||
const tracker: PageTracker = this.register(key);
|
const tracker: PageTracker = this.register(key);
|
||||||
|
|
||||||
if (tracker.pages != undefined) {
|
if (tracker.pages != undefined) {
|
||||||
@@ -25,11 +28,11 @@ class PageTrackerMap {
|
|||||||
tracker.pages = pages();
|
tracker.pages = pages();
|
||||||
return tracker.pages;
|
return tracker.pages;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewPersistence {
|
export class ViewPersistence {
|
||||||
static readonly chatPages = new PageTracker();
|
static readonly chatPages = new PageTracker();
|
||||||
static readonly taskPages = new PageTrackerMap();
|
static readonly taskPages = new PageTrackerMap();
|
||||||
static readonly boardPages = new PageTrackerMap();
|
static readonly boardPages = new PageTrackerMap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,8 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
chatModel.chatMessageHandlerManager.setHandler(this.chatModel.id,
|
chatModel.chatMessageHandlerManager.setHandler(
|
||||||
|
this.chatModel.id,
|
||||||
(chatMessage: ChatMessage) => {
|
(chatMessage: ChatMessage) => {
|
||||||
this.messagePageViewModel.showChatMessage(chatMessage);
|
this.messagePageViewModel.showChatMessage(chatMessage);
|
||||||
this.updateReadStatus();
|
this.updateReadStatus();
|
||||||
@@ -181,7 +182,8 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
|||||||
this.notificationViewModel.showNotification(chatMessage);
|
this.notificationViewModel.showNotification(chatMessage);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
chatModel.reactionHandlerManager.setHandler(this.chatModel.id,
|
chatModel.reactionHandlerManager.setHandler(
|
||||||
|
this.chatModel.id,
|
||||||
(reaction: ChatMessageReaction) => {
|
(reaction: ChatMessageReaction) => {
|
||||||
this.messagePageViewModel.handleReaction(reaction);
|
this.messagePageViewModel.handleReaction(reaction);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import FileTransferModel from "../../Model/Global/fileTransferModel";
|
|||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
export default class CoreViewModel {
|
export default class CoreViewModel {
|
||||||
readonly BUILD = "Build 26.04.14.A";
|
readonly BUILD = "Build 26.04.14.B";
|
||||||
|
|
||||||
translations: Translations;
|
translations: Translations;
|
||||||
|
|
||||||
|
|||||||
@@ -173,11 +173,13 @@ export default class FileTransferViewModel extends Context {
|
|||||||
constructor(public readonly coreViewModel: CoreViewModel) {
|
constructor(public readonly coreViewModel: CoreViewModel) {
|
||||||
super("file-transfer");
|
super("file-transfer");
|
||||||
|
|
||||||
this.coreViewModel.fileTransferModel.fileHandlerManager.setHandler("file-transfer-view-model",
|
this.coreViewModel.fileTransferModel.fileHandlerManager.setHandler(
|
||||||
|
"file-transfer-view-model",
|
||||||
this.handleReceivedFile,
|
this.handleReceivedFile,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.coreViewModel.fileTransferModel.readyToSendHandlerManager.setHandler("file-transfer-view-model",
|
this.coreViewModel.fileTransferModel.readyToSendHandlerManager.setHandler(
|
||||||
|
"file-transfer-view-model",
|
||||||
() => this.initiateTransfer(),
|
() => this.initiateTransfer(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
this.name.value,
|
this.name.value,
|
||||||
this.color.value,
|
this.color.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.taskPageViewModel.updateBoard(newBoardInfoFileContent);
|
this.taskPageViewModel.updateBoard(newBoardInfoFileContent);
|
||||||
|
|
||||||
this.taskPageViewModel.selectBoard(this);
|
this.taskPageViewModel.selectBoard(this);
|
||||||
@@ -254,6 +255,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
public readonly boardInfo: BoardInfoFileContent,
|
public readonly boardInfo: BoardInfoFileContent,
|
||||||
) {
|
) {
|
||||||
super(coreViewModel, chatViewModel, boardsAndTasksModel, "board");
|
super(coreViewModel, chatViewModel, boardsAndTasksModel, "board");
|
||||||
|
console.log("NEW BOARD VM")
|
||||||
|
|
||||||
// load
|
// load
|
||||||
this.loadListRelevantData();
|
this.loadListRelevantData();
|
||||||
@@ -275,10 +277,16 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
|
|
||||||
this.selectedPage.subscribeSilent(() => {
|
this.selectedPage.subscribeSilent(() => {
|
||||||
this.storeLastUsedView();
|
this.storeLastUsedView();
|
||||||
|
console.log(
|
||||||
|
"SELECTED PAGE",
|
||||||
|
this.selectedPage.value,
|
||||||
|
this.contextId,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
boardsAndTasksModel.taskHandlerManager.setHandler(this.boardInfo.fileId,
|
boardsAndTasksModel.taskHandlerManager.setHandler(
|
||||||
|
this.boardInfo.fileId,
|
||||||
(taskFileContent: TaskFileContent) => {
|
(taskFileContent: TaskFileContent) => {
|
||||||
if (taskFileContent.boardId != this.boardInfo.fileId) return;
|
if (taskFileContent.boardId != this.boardInfo.fileId) return;
|
||||||
this.showTask(taskFileContent);
|
this.showTask(taskFileContent);
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
boardsAndTasksModel.taskHandlerManager.setHandler("calendar" + this.chatViewModel.chatModel.id,
|
boardsAndTasksModel.taskHandlerManager.setHandler(
|
||||||
|
"calendar" + this.chatViewModel.chatModel.id,
|
||||||
(taskFileContent: TaskFileContent) => {
|
(taskFileContent: TaskFileContent) => {
|
||||||
this.showTask(taskFileContent);
|
this.showTask(taskFileContent);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
showBoardInList = (boardInfo: BoardInfoFileContent): void => {
|
showBoardInList = (boardInfo: BoardInfoFileContent): void => {
|
||||||
|
if (this.boardViewModels.value.has(boardInfo.fileId)) return;
|
||||||
|
|
||||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.chatViewModel,
|
this.chatViewModel,
|
||||||
@@ -99,9 +101,13 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
selectBoard = (boardViewModel: BoardViewModel): void => {
|
selectBoard = (boardViewModel: BoardViewModel): void => {
|
||||||
this.selectedBoardId.value = boardViewModel.boardInfo.fileId;
|
|
||||||
this.chatViewModel.displayedColor.value = boardViewModel.color.value;
|
this.chatViewModel.displayedColor.value = boardViewModel.color.value;
|
||||||
|
|
||||||
|
if (this.selectedBoardId.value == boardViewModel.boardInfo.fileId) {
|
||||||
|
return this.updateContexts();
|
||||||
|
}
|
||||||
|
this.selectedBoardId.value = boardViewModel.boardInfo.fileId;
|
||||||
|
|
||||||
this.storeLastUsedBoard();
|
this.storeLastUsedBoard();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -144,10 +150,11 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
|||||||
// load
|
// load
|
||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
this.boardViewModels.clear();
|
|
||||||
|
|
||||||
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
|
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
|
||||||
for (const boardId of boardIds) {
|
for (const boardId of boardIds) {
|
||||||
|
if (this.boardViewModels.value.has(boardId)) continue;
|
||||||
|
|
||||||
const boardInfo: BoardInfoFileContent | null =
|
const boardInfo: BoardInfoFileContent | null =
|
||||||
this.boardsAndTasksModel.getBoardInfo(boardId);
|
this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||||
if (boardInfo == null) continue;
|
if (boardInfo == null) continue;
|
||||||
@@ -174,7 +181,8 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
|||||||
this.selectedBoardId.subscribeSilent(this.updateContexts);
|
this.selectedBoardId.subscribeSilent(this.updateContexts);
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
boardsAndTasksModel.boardHandlerManager.setHandler("task-page" + this.chatViewModel.chatModel.id,
|
boardsAndTasksModel.boardHandlerManager.setHandler(
|
||||||
|
"task-page" + this.chatViewModel.chatModel.id,
|
||||||
(boardInfoFileContent: BoardInfoFileContent) => {
|
(boardInfoFileContent: BoardInfoFileContent) => {
|
||||||
this.showBoardInList(boardInfoFileContent);
|
this.showBoardInList(boardInfoFileContent);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
|
|||||||
@@ -86,12 +86,12 @@ export default class TaskViewModel extends Context {
|
|||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
this.coreViewModel.context = this;
|
this.coreViewModel.context = this;
|
||||||
this.containingModel.selectTask(this);
|
this.containingViewModel.selectTask(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
this.coreViewModel.closeContext(this.contextId);
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.containingModel.closeTask();
|
this.containingViewModel.closeTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
closeAndDiscard = (): void => {
|
closeAndDiscard = (): void => {
|
||||||
@@ -106,7 +106,7 @@ export default class TaskViewModel extends Context {
|
|||||||
|
|
||||||
updateIndex = (): void => {
|
updateIndex = (): void => {
|
||||||
const index: number =
|
const index: number =
|
||||||
this.containingModel.taskIndexManager.getIndex(this);
|
this.containingViewModel.taskIndexManager.getIndex(this);
|
||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ export default class TaskViewModel extends Context {
|
|||||||
|
|
||||||
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
||||||
|
|
||||||
this.containingModel.showTask(newTaskFileContent);
|
this.containingViewModel.showTask(newTaskFileContent);
|
||||||
this.containingModel.updateTaskIndices();
|
this.containingViewModel.updateTaskIndices();
|
||||||
|
|
||||||
this.updateSuggestions();
|
this.updateSuggestions();
|
||||||
};
|
};
|
||||||
@@ -159,7 +159,7 @@ export default class TaskViewModel extends Context {
|
|||||||
this.task.boardId,
|
this.task.boardId,
|
||||||
this.task.fileId,
|
this.task.fileId,
|
||||||
);
|
);
|
||||||
this.containingModel.removeTaskFromView(this.task);
|
this.containingViewModel.removeTaskFromView(this.task);
|
||||||
};
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
@@ -213,7 +213,7 @@ export default class TaskViewModel 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,
|
||||||
public readonly containingModel: TaskContainingPageViewModel,
|
public readonly containingViewModel: TaskContainingPageViewModel,
|
||||||
public task: TaskFileContent,
|
public task: TaskFileContent,
|
||||||
) {
|
) {
|
||||||
super("task");
|
super("task");
|
||||||
|
|||||||
Reference in New Issue
Block a user