integrate context with window.history API
This commit is contained in:
@@ -9,7 +9,6 @@ import ChatViewModel, { ChatPageTypes } from "../Chat/chatViewModel";
|
||||
import { Colors } from "../../colors";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import SearchViewModel from "../Utility/searchViewModel";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
||||
import TaskPageViewModel from "./taskPageViewModel";
|
||||
import TaskViewModel from "./taskViewModel";
|
||||
@@ -164,6 +163,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
|
||||
close = (): void => {
|
||||
this.taskPageViewModel.closeBoard();
|
||||
this.taskPageViewModel.storeLastUsedBoard();
|
||||
this.taskViewModels.clear();
|
||||
};
|
||||
|
||||
@@ -246,6 +246,14 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
this.loadSearchSuggestions();
|
||||
};
|
||||
|
||||
// exit
|
||||
handleContextClose = (fromHistoryEvent: boolean): void => {
|
||||
this.taskPageViewModel.handleBoardClosed(this);
|
||||
|
||||
if (!fromHistoryEvent) return;
|
||||
this.taskPageViewModel.storeLastUsedBoard();
|
||||
}
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public readonly coreViewModel: CoreViewModel,
|
||||
@@ -276,11 +284,6 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
|
||||
this.selectedPage.subscribeSilent(() => {
|
||||
this.storeLastUsedView();
|
||||
console.log(
|
||||
"SELECTED PAGE",
|
||||
this.selectedPage.value,
|
||||
this.contextId,
|
||||
);
|
||||
});
|
||||
|
||||
// handlers
|
||||
|
||||
@@ -104,7 +104,8 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
||||
this.chatViewModel.displayedColor.value = boardViewModel.color.value;
|
||||
|
||||
if (this.selectedBoardId.value == boardViewModel.boardInfo.fileId) {
|
||||
return this.updateContexts();
|
||||
this.updateContexts();
|
||||
return;
|
||||
}
|
||||
this.selectedBoardId.value = boardViewModel.boardInfo.fileId;
|
||||
|
||||
@@ -112,12 +113,14 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
||||
};
|
||||
|
||||
closeBoard = (): void => {
|
||||
this.closeContext();
|
||||
this.closeCurrentContext();
|
||||
}
|
||||
|
||||
handleBoardClosed = (boardViewModel: BoardViewModel): void => {
|
||||
if (boardViewModel.boardInfo.fileId != this.selectedBoardId.value) return;
|
||||
|
||||
this.selectedBoardId.value = undefined;
|
||||
this.chatViewModel.resetColor();
|
||||
|
||||
this.storeLastUsedBoard();
|
||||
};
|
||||
|
||||
updateBoardIndices = (): void => {
|
||||
@@ -149,7 +152,7 @@ export default class TaskPageViewModel extends ContextHost<string> {
|
||||
|
||||
// load
|
||||
loadData = (): void => {
|
||||
this.closeContext();
|
||||
this.closeCurrentContext();
|
||||
|
||||
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
|
||||
for (const boardId of boardIds) {
|
||||
|
||||
@@ -89,11 +89,6 @@ export default class TaskViewModel extends Context {
|
||||
this.containingViewModel.selectTask(this);
|
||||
};
|
||||
|
||||
close = (): void => {
|
||||
this.coreViewModel.closeContext(this.contextId);
|
||||
this.containingViewModel.closeTask();
|
||||
};
|
||||
|
||||
closeAndDiscard = (): void => {
|
||||
this.close();
|
||||
this.loadTaskData();
|
||||
@@ -203,11 +198,18 @@ export default class TaskViewModel extends Context {
|
||||
this.date.value = this.task.date ?? "";
|
||||
this.time.value = this.task.time ?? "";
|
||||
|
||||
this.selectedVersionId.value = this.task.fileContentId;
|
||||
|
||||
this.updateSuggestions();
|
||||
};
|
||||
|
||||
// exit
|
||||
close = (): void => {
|
||||
this.coreViewModel.closeContext(this.contextId);
|
||||
};
|
||||
|
||||
handleContextClose = (): void => {
|
||||
this.containingViewModel.closeTask();
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public readonly coreViewModel: CoreViewModel,
|
||||
|
||||
Reference in New Issue
Block a user