add context, rewrite keystrokes
This commit is contained in:
Vendored
+886
-704
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ export function MessagePage(
|
|||||||
<span>
|
<span>
|
||||||
<button
|
<button
|
||||||
class="ghost"
|
class="ghost"
|
||||||
on:click={messagePageViewModel.openFilterModal}
|
on:click={messagePageViewModel.showFilterModal}
|
||||||
aria-label={
|
aria-label={
|
||||||
coreViewModel.translations.chatPage.message
|
coreViewModel.translations.chatPage.message
|
||||||
.filterMessagesButtonAudioLabel
|
.filterMessagesButtonAudioLabel
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export function MessageFilterModal<T>(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<button on:click={messagePageViewModel.closeFilterModal}>
|
<button on:click={messagePageViewModel.hideFilterModal}>
|
||||||
{coreViewModel.translations.general.closeButton}
|
{coreViewModel.translations.general.closeButton}
|
||||||
<span class="icon">close</span>
|
<span class="icon">close</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -27,12 +27,7 @@ export function TaskSettingsModal(
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div class="modal" open>
|
||||||
class="modal"
|
|
||||||
open
|
|
||||||
keystroke:s={taskViewModel.closeAndSave}
|
|
||||||
keystroke:Escape={taskViewModel.closeAndDiscard}
|
|
||||||
>
|
|
||||||
<div>
|
<div>
|
||||||
<main>
|
<main>
|
||||||
<h2>
|
<h2>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export enum CommonKeys {
|
||||||
|
Home = " ",
|
||||||
|
Filter = "=",
|
||||||
|
Reset = "-",
|
||||||
|
CloseOrCancel = "backspace",
|
||||||
|
Apply = "enter",
|
||||||
|
Settings = ",",
|
||||||
|
}
|
||||||
@@ -133,7 +133,6 @@ export default class ChatMessageViewModel {
|
|||||||
this.loadData();
|
this.loadData();
|
||||||
|
|
||||||
this.messagePageViewModel.reactionFilter.subscribe((content) => {
|
this.messagePageViewModel.reactionFilter.subscribe((content) => {
|
||||||
console.log(content, content == undefined);
|
|
||||||
if (content == undefined) {
|
if (content == undefined) {
|
||||||
this.isHidden.value = false;
|
this.isHidden.value = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import StorageModel, {
|
|||||||
|
|
||||||
import ChatListViewModel from "./chatListViewModel";
|
import ChatListViewModel from "./chatListViewModel";
|
||||||
import { Colors } from "../../colors";
|
import { Colors } from "../../colors";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context, ContextHost } from "../Global/coreViewModel";
|
||||||
import { Entry } from "../../View/Components/option";
|
import { Entry } from "../../View/Components/option";
|
||||||
import MessagePageViewModel from "../Pages/messagePageViewModel";
|
import MessagePageViewModel from "../Pages/messagePageViewModel";
|
||||||
import SettingsPageViewModel from "../Pages/settingsPageViewModel";
|
import SettingsPageViewModel from "../Pages/settingsPageViewModel";
|
||||||
@@ -22,8 +22,12 @@ import SettingsViewModel from "../Global/settingsViewModel";
|
|||||||
import TaskPageViewModel from "../Pages/taskPageViewModel";
|
import TaskPageViewModel from "../Pages/taskPageViewModel";
|
||||||
import ConnectionViewModel from "../Global/connectionViewModel";
|
import ConnectionViewModel from "../Global/connectionViewModel";
|
||||||
import NotificationViewModel from "../Global/notificationViewModel";
|
import NotificationViewModel from "../Global/notificationViewModel";
|
||||||
|
import { v4 } from "uuid";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
|
export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
||||||
|
contextDebugDescription = "chat";
|
||||||
|
|
||||||
export default class ChatViewModel {
|
|
||||||
calendarViewModel: CalendarPageViewModel;
|
calendarViewModel: CalendarPageViewModel;
|
||||||
taskPageViewModel: TaskPageViewModel;
|
taskPageViewModel: TaskPageViewModel;
|
||||||
messagePageViewModel: MessagePageViewModel;
|
messagePageViewModel: MessagePageViewModel;
|
||||||
@@ -34,47 +38,36 @@ export default class ChatViewModel {
|
|||||||
selectedPage: React.State<ChatPageTypes> = new React.State<any>(
|
selectedPage: React.State<ChatPageTypes> = new React.State<any>(
|
||||||
ChatPageTypes.Messages,
|
ChatPageTypes.Messages,
|
||||||
);
|
);
|
||||||
|
pageContexts = new React.MapState<Context>();
|
||||||
|
|
||||||
index: React.State<number> = new React.State(0);
|
index: React.State<number> = new React.State(0);
|
||||||
hasUnreadMessages: React.State<boolean> = new React.State(false);
|
hasUnreadMessages: React.State<boolean> = new React.State(false);
|
||||||
|
|
||||||
taskBoardSuggestions: React.MapState<Entry> = new React.MapState();
|
taskBoardSuggestions: React.MapState<Entry> = new React.MapState();
|
||||||
|
|
||||||
|
// context
|
||||||
|
get isOpen(): boolean {
|
||||||
|
return this.chatListViewModel.selectedChat.value == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
get contextSelection(): ChatPageTypes {
|
||||||
|
return this.selectedPage.value;
|
||||||
|
}
|
||||||
|
|
||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
|
this.coreViewModel.context = this;
|
||||||
this.chatListViewModel.openChat(this);
|
this.chatListViewModel.openChat(this);
|
||||||
document.body.addEventListener("keydown", this.handleKeystroke);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.chatListViewModel.closeChat();
|
this.chatListViewModel.closeChat();
|
||||||
document.body.removeEventListener("keydown", this.handleKeystroke);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleKeystroke = (e: KeyboardEvent): any => {
|
openPage = (page: ChatPageTypes): void => {
|
||||||
if (!e.metaKey && !e.ctrlKey) return;
|
this.closeContext();
|
||||||
|
this.selectedPage.value = page;
|
||||||
switch (e.key) {
|
|
||||||
case "e":
|
|
||||||
this.close();
|
|
||||||
break;
|
|
||||||
case "1":
|
|
||||||
this.selectedPage.value = ChatPageTypes.Messages;
|
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
this.selectedPage.value = ChatPageTypes.Tasks;
|
|
||||||
break;
|
|
||||||
case "3":
|
|
||||||
this.selectedPage.value = ChatPageTypes.Calendar;
|
|
||||||
break;
|
|
||||||
case ",":
|
|
||||||
this.selectedPage.value = ChatPageTypes.Settings;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
closeSubPages = (): void => {};
|
closeSubPages = (): void => {};
|
||||||
@@ -159,6 +152,8 @@ export default class ChatViewModel {
|
|||||||
public connectionViewModel: ConnectionViewModel,
|
public connectionViewModel: ConnectionViewModel,
|
||||||
public chatListViewModel: ChatListViewModel,
|
public chatListViewModel: ChatListViewModel,
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
// page viewModels
|
// page viewModels
|
||||||
this.calendarViewModel = new CalendarPageViewModel(
|
this.calendarViewModel = new CalendarPageViewModel(
|
||||||
coreViewModel,
|
coreViewModel,
|
||||||
@@ -200,6 +195,23 @@ export default class ChatViewModel {
|
|||||||
this.resetColor();
|
this.resetColor();
|
||||||
this.loadInfo();
|
this.loadInfo();
|
||||||
this.subscribeReadStatus();
|
this.subscribeReadStatus();
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.Home, this.close);
|
||||||
|
this.registerKeyStroke("h", () =>
|
||||||
|
this.openPage(ChatPageTypes.Messages),
|
||||||
|
);
|
||||||
|
this.registerKeyStroke("j", () => this.openPage(ChatPageTypes.Tasks));
|
||||||
|
this.registerKeyStroke("k", () =>
|
||||||
|
this.openPage(ChatPageTypes.Calendar),
|
||||||
|
);
|
||||||
|
this.registerKeyStroke(CommonKeys.Settings, () =>
|
||||||
|
this.openPage(ChatPageTypes.Settings),
|
||||||
|
);
|
||||||
|
|
||||||
|
// context
|
||||||
|
this.chatListViewModel.selectedChat.subscribeSilent(this.updateContexts);
|
||||||
|
this.selectedPage.subscribeSilent(this.updateContexts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,55 @@ import StorageModel from "../../Model/Global/storageModel";
|
|||||||
import ConnectionModel from "../../Model/Global/connectionModel";
|
import ConnectionModel from "../../Model/Global/connectionModel";
|
||||||
import ChatListModel from "../../Model/Chat/chatListModel";
|
import ChatListModel from "../../Model/Chat/chatListModel";
|
||||||
import FileTransferModel from "../../Model/Global/fileTransferModel";
|
import FileTransferModel from "../../Model/Global/fileTransferModel";
|
||||||
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
export default class CoreViewModel {
|
export default class CoreViewModel {
|
||||||
readonly BUILD = "Build 26.04.12.A";
|
readonly BUILD = "Build 26.04.12.A";
|
||||||
|
|
||||||
translations: Translations;
|
translations: Translations;
|
||||||
|
|
||||||
|
// CONTEXT
|
||||||
|
private contextStack = new Map<string, Context>();
|
||||||
|
get contexts(): Context[] {
|
||||||
|
return [...this.contextStack.values()];
|
||||||
|
}
|
||||||
|
get context(): Context | undefined {
|
||||||
|
return this.contexts.pop();
|
||||||
|
}
|
||||||
|
logContexts = (): void => {
|
||||||
|
console.log(
|
||||||
|
"context",
|
||||||
|
this.contexts.map(
|
||||||
|
(x) => x.contextDebugDescription + "-" + x.contextId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
set context(context: Context) {
|
||||||
|
if (this.contextStack.has(context.contextId)) return;
|
||||||
|
this.contextStack.set(context.contextId, context);
|
||||||
|
this.logContexts();
|
||||||
|
}
|
||||||
|
closeContext = (contextId: string): void => {
|
||||||
|
if (!this.contexts.map(context=>context.contextId).includes(contextId)) return;
|
||||||
|
while (this.contexts.length > 0) {
|
||||||
|
const currentContext = this.context;
|
||||||
|
this.contextStack.delete(currentContext.contextId);
|
||||||
|
if (currentContext.contextId == contextId) break;
|
||||||
|
}
|
||||||
|
this.logContexts();
|
||||||
|
};
|
||||||
|
|
||||||
|
handleKeyDown = (e: KeyboardEvent): void => {
|
||||||
|
if (!CoreViewModel.checkIsKeystroke(e)) return;
|
||||||
|
const contexts = this.contexts;
|
||||||
|
while (contexts.length > 0) {
|
||||||
|
const currentContext = contexts.pop();
|
||||||
|
if (!currentContext) contexts;
|
||||||
|
const isHandled: boolean = currentContext.handleKeystroke(e);
|
||||||
|
if (isHandled == true) break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// DRAG & DROP
|
// DRAG & DROP
|
||||||
draggedObject: React.State<any> = new React.State<any>(undefined);
|
draggedObject: React.State<any> = new React.State<any>(undefined);
|
||||||
|
|
||||||
@@ -32,5 +75,71 @@ export default class CoreViewModel {
|
|||||||
) {
|
) {
|
||||||
this.translations =
|
this.translations =
|
||||||
allTranslations[settingsModel.language] || allTranslations.en;
|
allTranslations[settingsModel.language] || allTranslations.en;
|
||||||
|
|
||||||
|
document.body.addEventListener("keydown", this.handleKeyDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
// util
|
||||||
|
static checkIsKeystroke(e: KeyboardEvent): boolean {
|
||||||
|
return (e.metaKey || e.ctrlKey) && e.shiftKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Context {
|
||||||
|
contextId = v4();
|
||||||
|
contextDebugDescription: string;
|
||||||
|
keystrokes = new Map<string, () => void>();
|
||||||
|
|
||||||
|
handleKeystroke = (e: KeyboardEvent): boolean => {
|
||||||
|
const fn = this.keystrokes.get(e.key.toLowerCase());
|
||||||
|
if (!fn) return false;
|
||||||
|
e.preventDefault();
|
||||||
|
fn();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
close: () => void;
|
||||||
|
|
||||||
|
registerKeyStroke = (key: string, fn: () => void): void => {
|
||||||
|
this.keystrokes.set(key, fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ContextHost<T> extends Context {
|
||||||
|
coreViewModel: CoreViewModel;
|
||||||
|
contexts = new Map<T, Context>();
|
||||||
|
currentContext = new React.State<Context | undefined>(undefined);
|
||||||
|
|
||||||
|
get isOpen(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
get contextSelection(): T | undefined {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerContext = (key: T, context: Context): void => {
|
||||||
|
this.contexts.set(key, context);
|
||||||
|
};
|
||||||
|
|
||||||
|
closeContext = (): void => {
|
||||||
|
if (this.currentContext.value) {
|
||||||
|
this.coreViewModel.closeContext(this.currentContext.value.contextId);
|
||||||
|
}
|
||||||
|
this.currentContext.value = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
updateContexts = (): void => {
|
||||||
|
if (this.isOpen == false) return;
|
||||||
|
|
||||||
|
const selectedContext = this.contexts.get(this.contextSelection);
|
||||||
|
if (!selectedContext) return;
|
||||||
|
if (selectedContext != this.currentContext.value) {
|
||||||
|
this.closeContext();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.coreViewModel.logContexts();
|
||||||
|
|
||||||
|
this.coreViewModel.context = selectedContext;
|
||||||
|
this.currentContext.value = selectedContext;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ import StorageModel, {
|
|||||||
} from "../../Model/Global/storageModel";
|
} from "../../Model/Global/storageModel";
|
||||||
|
|
||||||
import ChatModel from "../../Model/Chat/chatModel";
|
import ChatModel from "../../Model/Chat/chatModel";
|
||||||
import CoreViewModel from "./coreViewModel";
|
import CoreViewModel, { Context } from "./coreViewModel";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
|
export default class FileTransferViewModel extends Context {
|
||||||
|
contextDebugDescription = "transfer";
|
||||||
|
|
||||||
export default class FileTransferViewModel {
|
|
||||||
// state
|
// state
|
||||||
presentedModal: React.State<FileTransferModals | undefined> =
|
presentedModal: React.State<FileTransferModals | undefined> =
|
||||||
new React.State<any>(undefined);
|
new React.State<any>(undefined);
|
||||||
@@ -116,6 +119,7 @@ export default class FileTransferViewModel {
|
|||||||
|
|
||||||
// view
|
// view
|
||||||
showDirectionSelectionModal = (): void => {
|
showDirectionSelectionModal = (): void => {
|
||||||
|
this.coreViewModel.context = this;
|
||||||
this.presentedModal.value = FileTransferModals.DirectionSelection;
|
this.presentedModal.value = FileTransferModals.DirectionSelection;
|
||||||
this.getOptions();
|
this.getOptions();
|
||||||
};
|
};
|
||||||
@@ -162,11 +166,14 @@ export default class FileTransferViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
hideModal = (): void => {
|
hideModal = (): void => {
|
||||||
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.presentedModal.value = undefined;
|
this.presentedModal.value = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(public coreViewModel: CoreViewModel) {
|
constructor(public coreViewModel: CoreViewModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler(
|
this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler(
|
||||||
this.handleReceivedFile,
|
this.handleReceivedFile,
|
||||||
);
|
);
|
||||||
@@ -174,6 +181,9 @@ export default class FileTransferViewModel {
|
|||||||
this.coreViewModel.fileTransferModel.readyToSendHandlerManager.addHandler(
|
this.coreViewModel.fileTransferModel.readyToSendHandlerManager.addHandler(
|
||||||
() => this.initiateTransfer(),
|
() => this.initiateTransfer(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideModal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import CoreViewModel from "./coreViewModel";
|
import CoreViewModel, { Context } from "./coreViewModel";
|
||||||
import { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
|
import { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
|
export default class SettingsViewModel extends Context {
|
||||||
|
contextDebugDescription = "settings";
|
||||||
|
|
||||||
export default class SettingsViewModel {
|
|
||||||
// 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("");
|
||||||
@@ -43,10 +46,12 @@ export default class SettingsViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
showSettingsModal = (): void => {
|
showSettingsModal = (): void => {
|
||||||
|
this.coreViewModel.context = this;
|
||||||
this.isShowingSettingsModal.value = true;
|
this.isShowingSettingsModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
hideSettingsModal = (): void => {
|
hideSettingsModal = (): void => {
|
||||||
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.isShowingSettingsModal.value = false;
|
this.isShowingSettingsModal.value = false;
|
||||||
if (this.requiresReload.value == true) {
|
if (this.requiresReload.value == true) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -68,6 +73,8 @@ export default class SettingsViewModel {
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(public coreViewModel: CoreViewModel) {
|
constructor(public coreViewModel: CoreViewModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.username.value = coreViewModel.settingsModel.username;
|
this.username.value = coreViewModel.settingsModel.username;
|
||||||
this.usernameInput.value = coreViewModel.settingsModel.username;
|
this.usernameInput.value = coreViewModel.settingsModel.username;
|
||||||
this.firstDayOfWeek.value = coreViewModel.settingsModel.firstDayOfWeek;
|
this.firstDayOfWeek.value = coreViewModel.settingsModel.firstDayOfWeek;
|
||||||
@@ -91,6 +98,9 @@ export default class SettingsViewModel {
|
|||||||
SettingsViewModel.generateThemeMedia().addEventListener("change", () =>
|
SettingsViewModel.generateThemeMedia().addEventListener("change", () =>
|
||||||
this.applyTheme(),
|
this.applyTheme(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideSettingsModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static generateThemeMedia(): MediaQueryList {
|
static generateThemeMedia(): MediaQueryList {
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ import StorageModel, {
|
|||||||
PATH_COMPONENT_SEPARATOR,
|
PATH_COMPONENT_SEPARATOR,
|
||||||
} from "../../Model/Global/storageModel";
|
} from "../../Model/Global/storageModel";
|
||||||
|
|
||||||
import CoreViewModel from "./coreViewModel";
|
import CoreViewModel, { Context } from "./coreViewModel";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
|
export default class StorageViewModel extends Context {
|
||||||
|
contextDebugDescription = "storage";
|
||||||
|
|
||||||
export default class StorageViewModel {
|
|
||||||
// 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(
|
||||||
@@ -48,10 +51,12 @@ export default class StorageViewModel {
|
|||||||
|
|
||||||
// view
|
// view
|
||||||
showStorageModal = (): void => {
|
showStorageModal = (): void => {
|
||||||
|
this.coreViewModel.context = this;
|
||||||
this.isShowingStorageModal.value = true;
|
this.isShowingStorageModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
hideStorageModal = (): void => {
|
hideStorageModal = (): void => {
|
||||||
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
if (this.didMakeChanges.value == true) {
|
if (this.didMakeChanges.value == true) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
return;
|
||||||
@@ -61,6 +66,8 @@ export default class StorageViewModel {
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(public coreViewModel: CoreViewModel) {
|
constructor(public coreViewModel: CoreViewModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.selectedFileName = React.createProxyState(
|
this.selectedFileName = React.createProxyState(
|
||||||
[this.selectedPath],
|
[this.selectedPath],
|
||||||
() => StorageModel.getFileNameFromString(this.selectedPath.value),
|
() => StorageModel.getFileNameFromString(this.selectedPath.value),
|
||||||
@@ -69,5 +76,8 @@ export default class StorageViewModel {
|
|||||||
[this.selectedPath],
|
[this.selectedPath],
|
||||||
() => this.getSelectedItemContent(),
|
() => this.getSelectedItemContent(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideStorageModal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ import StorageModel from "../../Model/Global/storageModel";
|
|||||||
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
||||||
import TaskPageViewModel from "./taskPageViewModel";
|
import TaskPageViewModel from "./taskPageViewModel";
|
||||||
import TaskViewModel from "./taskViewModel";
|
import TaskViewModel from "./taskViewModel";
|
||||||
|
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);
|
||||||
@@ -180,6 +183,10 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
this.isPresentingFilterModal.value = false;
|
this.isPresentingFilterModal.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resetFilter = (): void => {
|
||||||
|
this.searchViewModel.search("");
|
||||||
|
};
|
||||||
|
|
||||||
updateIndex = (): void => {
|
updateIndex = (): void => {
|
||||||
const index: number =
|
const index: number =
|
||||||
this.taskPageViewModel.boardIndexManager.getIndex(this);
|
this.taskPageViewModel.boardIndexManager.getIndex(this);
|
||||||
@@ -295,6 +302,13 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
[this.searchViewModel.appliedQuery],
|
[this.searchViewModel.appliedQuery],
|
||||||
() => this.searchViewModel.appliedQuery.value != "",
|
() => this.searchViewModel.appliedQuery.value != "",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal);
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideFilterModal);
|
||||||
|
this.registerKeyStroke(CommonKeys.Reset, this.resetFilter);
|
||||||
|
|
||||||
|
this.taskPageViewModel.registerContext(this.boardInfo.fileId, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,17 @@ import BoardsAndTasksModel, {
|
|||||||
} from "../../Model/Files/boardsAndTasksModel";
|
} from "../../Model/Files/boardsAndTasksModel";
|
||||||
import CalendarModel, { MonthGrid } from "../../Model/Files/calendarModel";
|
import CalendarModel, { MonthGrid } from "../../Model/Files/calendarModel";
|
||||||
|
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel, { ChatPageTypes } from "../Chat/chatViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
import StorageModel from "../../Model/Global/storageModel";
|
|
||||||
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
||||||
import TaskViewModel from "./taskViewModel";
|
import TaskViewModel from "./taskViewModel";
|
||||||
|
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(
|
||||||
@@ -208,6 +210,13 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
|
|||||||
|
|
||||||
// initiate
|
// initiate
|
||||||
this.showToday();
|
this.showToday();
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.Reset, this.showToday);
|
||||||
|
this.registerKeyStroke("p", this.showNextMonth);
|
||||||
|
this.registerKeyStroke("o", this.showPreviousMonth);
|
||||||
|
|
||||||
|
this.chatViewModel.registerContext(ChatPageTypes.Calendar, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
import ConnectionViewModel from "../Global/connectionViewModel";
|
||||||
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
||||||
|
import FileTransferViewModel from "../Global/fileTransferViewModel";
|
||||||
|
import SettingsViewModel from "../Global/settingsViewModel";
|
||||||
|
import StorageViewModel from "../Global/storageViewModel";
|
||||||
|
|
||||||
|
export default class HomeViewModel extends Context {
|
||||||
|
contextDebugDescription = "home";
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public coreViewModel: CoreViewModel,
|
||||||
|
public settingsViewModel: SettingsViewModel,
|
||||||
|
public fileTransferViewModel: FileTransferViewModel,
|
||||||
|
public storageViewModel: StorageViewModel,
|
||||||
|
public connectionViewModel: ConnectionViewModel,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.coreViewModel.context = this;
|
||||||
|
|
||||||
|
this.registerKeyStroke(
|
||||||
|
CommonKeys.Settings,
|
||||||
|
this.settingsViewModel.showSettingsModal,
|
||||||
|
);
|
||||||
|
this.registerKeyStroke(
|
||||||
|
"d",
|
||||||
|
this.fileTransferViewModel.showDirectionSelectionModal,
|
||||||
|
);
|
||||||
|
this.registerKeyStroke("e", this.storageViewModel.showStorageModal);
|
||||||
|
this.registerKeyStroke("x", this.connectionViewModel.disconnect);
|
||||||
|
this.registerKeyStroke("c", this.connectionViewModel.connect);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,15 @@ import {
|
|||||||
ReactionSymbols,
|
ReactionSymbols,
|
||||||
} from "../../Model/Chat/chatModel";
|
} from "../../Model/Chat/chatModel";
|
||||||
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel, { ChatPageTypes } from "../Chat/chatViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
||||||
import SearchViewModel from "../Utility/searchViewModel";
|
import SearchViewModel from "../Utility/searchViewModel";
|
||||||
|
import { v4 } from "uuid";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
|
export default class MessagePageViewModel extends Context {
|
||||||
|
contextDebugDescription = "message-page";
|
||||||
|
|
||||||
export default class MessagePageViewModel {
|
|
||||||
// state
|
// state
|
||||||
chatMessageViewModels: React.MapState<ChatMessageViewModel> =
|
chatMessageViewModels: React.MapState<ChatMessageViewModel> =
|
||||||
new React.MapState();
|
new React.MapState();
|
||||||
@@ -89,11 +93,11 @@ export default class MessagePageViewModel {
|
|||||||
messageViewModel.handleReaction(reaction);
|
messageViewModel.handleReaction(reaction);
|
||||||
};
|
};
|
||||||
|
|
||||||
openFilterModal = (): void => {
|
showFilterModal = (): void => {
|
||||||
this.isFilterModalOpen.value = true;
|
this.isFilterModalOpen.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
closeFilterModal = (): void => {
|
hideFilterModal = (): void => {
|
||||||
this.isFilterModalOpen.value = false;
|
this.isFilterModalOpen.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,6 +109,11 @@ export default class MessagePageViewModel {
|
|||||||
this.reactionFilter.value = content;
|
this.reactionFilter.value = content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resetFilter = (): void => {
|
||||||
|
this.revokeReactionFilter();
|
||||||
|
this.searchViewModel.search("");
|
||||||
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
this.chatMessageViewModels.clear();
|
this.chatMessageViewModels.clear();
|
||||||
@@ -121,6 +130,9 @@ export default class MessagePageViewModel {
|
|||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
public chatViewModel: ChatViewModel,
|
public chatViewModel: ChatViewModel,
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
// states
|
||||||
this.cannotSendMessage = React.createProxyState(
|
this.cannotSendMessage = React.createProxyState(
|
||||||
[
|
[
|
||||||
this.chatViewModel.settingsViewModel.username,
|
this.chatViewModel.settingsViewModel.username,
|
||||||
@@ -144,5 +156,12 @@ export default class MessagePageViewModel {
|
|||||||
this.searchViewModel.appliedQuery.value != "" ||
|
this.searchViewModel.appliedQuery.value != "" ||
|
||||||
this.reactionFilter.value != undefined,
|
this.reactionFilter.value != undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal);
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideFilterModal);
|
||||||
|
this.registerKeyStroke(CommonKeys.Reset, this.resetFilter);
|
||||||
|
|
||||||
|
this.chatViewModel.registerContext(ChatPageTypes.Messages, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel, { ChatPageTypes } from "../Chat/chatViewModel";
|
||||||
import { Colors } from "../../colors";
|
import { Colors } from "../../colors";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
||||||
|
|
||||||
|
export default class SettingsPageViewModel extends Context {
|
||||||
|
contextDebugDescription = "settings";
|
||||||
|
|
||||||
export default class SettingsPageViewModel {
|
|
||||||
// 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("");
|
||||||
@@ -113,6 +115,8 @@ export default class SettingsPageViewModel {
|
|||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
public chatViewModel: ChatViewModel,
|
public chatViewModel: ChatViewModel,
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.loadListRelevantData();
|
this.loadListRelevantData();
|
||||||
|
|
||||||
this.cannotSetEncryptionKey = React.createProxyState(
|
this.cannotSetEncryptionKey = React.createProxyState(
|
||||||
@@ -125,5 +129,7 @@ export default class SettingsPageViewModel {
|
|||||||
this.color.subscribe((newColor) => {
|
this.color.subscribe((newColor) => {
|
||||||
this.applyColor(newColor);
|
this.applyColor(newColor);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.chatViewModel.registerContext(ChatPageTypes.Settings, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import BoardsAndTasksModel, {
|
|||||||
} from "../../Model/Files/boardsAndTasksModel";
|
} from "../../Model/Files/boardsAndTasksModel";
|
||||||
|
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel from "../Chat/chatViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
||||||
import { IndexManager } from "../../Model/Utility/utility";
|
import { IndexManager } from "../../Model/Utility/utility";
|
||||||
import TaskViewModel from "./taskViewModel";
|
import TaskViewModel from "./taskViewModel";
|
||||||
|
|
||||||
export default class TaskContainingPageViewModel {
|
export default class TaskContainingPageViewModel extends Context {
|
||||||
// state
|
// state
|
||||||
taskIndexManager: IndexManager<TaskViewModel> = new IndexManager(
|
taskIndexManager: IndexManager<TaskViewModel> = new IndexManager(
|
||||||
(taskViewModel: TaskViewModel) => taskViewModel.sortingString,
|
(taskViewModel: TaskViewModel) => taskViewModel.sortingString,
|
||||||
@@ -59,5 +59,7 @@ export default class TaskContainingPageViewModel {
|
|||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
public chatViewModel: ChatViewModel,
|
public chatViewModel: ChatViewModel,
|
||||||
public boardsAndTasksModel: BoardsAndTasksModel,
|
public boardsAndTasksModel: BoardsAndTasksModel,
|
||||||
) {}
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import BoardsAndTasksModel, {
|
|||||||
BoardInfoFileContent,
|
BoardInfoFileContent,
|
||||||
} from "../../Model/Files/boardsAndTasksModel";
|
} from "../../Model/Files/boardsAndTasksModel";
|
||||||
|
|
||||||
import BoardViewModel from "./boardViewModel";
|
import BoardViewModel, { BoardPageTypes } from "./boardViewModel";
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel, { ChatPageTypes } from "../Chat/chatViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context, ContextHost } from "../Global/coreViewModel";
|
||||||
import { IndexManager } from "../../Model/Utility/utility";
|
import { IndexManager } from "../../Model/Utility/utility";
|
||||||
|
|
||||||
export default class TaskPageViewModel {
|
export default class TaskPageViewModel extends ContextHost<string> {
|
||||||
|
contextDebugDescription = "task-page";
|
||||||
|
|
||||||
// data
|
// data
|
||||||
boardIndexManager: IndexManager<BoardViewModel> = new IndexManager(
|
boardIndexManager: IndexManager<BoardViewModel> = new IndexManager(
|
||||||
(boardViewModel: BoardViewModel) => boardViewModel.name.value,
|
(boardViewModel: BoardViewModel) => boardViewModel.name.value,
|
||||||
@@ -19,26 +21,33 @@ export default class TaskPageViewModel {
|
|||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
return [...this.boardsAndTasksModel.getViewPath()];
|
return [...this.boardsAndTasksModel.getViewPath()];
|
||||||
};
|
};
|
||||||
|
|
||||||
getBoardViewPath = (boardId): string[] => {
|
getBoardViewPath = (boardId): string[] => {
|
||||||
return [...this.getBasePath(), boardId];
|
return [...this.getBasePath(), boardId];
|
||||||
};
|
};
|
||||||
|
|
||||||
getLastUsedBoardPath = (): string[] => {
|
getLastUsedBoardPath = (): string[] => {
|
||||||
return [...this.getBasePath(), TaskPageViewModelSubPaths.LastUsedBoard];
|
return [...this.getBasePath(), TaskPageViewModelSubPaths.LastUsedBoard];
|
||||||
};
|
};
|
||||||
|
|
||||||
// state
|
// state
|
||||||
newBoardNameInput: React.State<string> = new React.State("");
|
newBoardNameInput: React.State<string> = new React.State("");
|
||||||
|
|
||||||
boardViewModels: React.MapState<BoardViewModel> = new React.MapState();
|
boardViewModels: React.MapState<BoardViewModel> = new React.MapState();
|
||||||
|
|
||||||
isShowingBoadList: React.State<boolean> = new React.State(true);
|
isShowingBoadList: React.State<boolean> = new React.State(true);
|
||||||
|
|
||||||
selectedBoardId: React.State<string | undefined> = new React.State<any>(
|
selectedBoardId: React.State<string | undefined> = new React.State<any>(
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// context
|
||||||
|
get isOpen(): boolean {
|
||||||
|
return (
|
||||||
|
this.chatViewModel.isOpen &&
|
||||||
|
this.chatViewModel.selectedPage.value == ChatPageTypes.Tasks
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get contextSelection(): string {
|
||||||
|
return this.selectedBoardId.value;
|
||||||
|
}
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotCreateBoard: React.State<boolean> = React.createProxyState(
|
cannotCreateBoard: React.State<boolean> = React.createProxyState(
|
||||||
[this.newBoardNameInput],
|
[this.newBoardNameInput],
|
||||||
@@ -98,6 +107,8 @@ export default class TaskPageViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
closeBoard = (): void => {
|
closeBoard = (): void => {
|
||||||
|
this.closeContext();
|
||||||
|
|
||||||
this.selectedBoardId.value = undefined;
|
this.selectedBoardId.value = undefined;
|
||||||
this.chatViewModel.resetColor();
|
this.chatViewModel.resetColor();
|
||||||
|
|
||||||
@@ -154,6 +165,8 @@ export default class TaskPageViewModel {
|
|||||||
public chatViewModel: ChatViewModel,
|
public chatViewModel: ChatViewModel,
|
||||||
public boardsAndTasksModel: BoardsAndTasksModel,
|
public boardsAndTasksModel: BoardsAndTasksModel,
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
this.chatViewModel = chatViewModel;
|
this.chatViewModel = chatViewModel;
|
||||||
|
|
||||||
this.loadData();
|
this.loadData();
|
||||||
@@ -165,6 +178,11 @@ export default class TaskPageViewModel {
|
|||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// context
|
||||||
|
this.chatViewModel.registerContext(ChatPageTypes.Tasks, this);
|
||||||
|
|
||||||
|
this.selectedBoardId.subscribeSilent(this.updateContexts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,16 @@ import BoardsAndTasksModel, {
|
|||||||
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
||||||
|
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel from "../Chat/chatViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
||||||
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
|
||||||
import { allowDrag } from "../../View/utility";
|
import { allowDrag } from "../../View/utility";
|
||||||
|
import { v4 } from "uuid";
|
||||||
|
import { CommonKeys } from "../../View/keystrokes";
|
||||||
|
|
||||||
export default class TaskViewModel {
|
export default class TaskViewModel extends Context {
|
||||||
|
contextDebugDescription = "task";
|
||||||
|
|
||||||
|
// util
|
||||||
get sortingString(): string {
|
get sortingString(): string {
|
||||||
const splitDate: string[] = this.date.value.split("-");
|
const splitDate: string[] = this.date.value.split("-");
|
||||||
const year = padZero(splitDate[0], 4);
|
const year = padZero(splitDate[0], 4);
|
||||||
@@ -82,21 +87,21 @@ export default class TaskViewModel {
|
|||||||
|
|
||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
|
this.coreViewModel.context = this;
|
||||||
this.containingModel.selectTask(this);
|
this.containingModel.selectTask(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
|
this.coreViewModel.closeContext(this.contextId);
|
||||||
this.containingModel.closeTask();
|
this.containingModel.closeTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
closeAndDiscard = (e: Event): void => {
|
closeAndDiscard = (): void => {
|
||||||
e.preventDefault();
|
|
||||||
this.close();
|
this.close();
|
||||||
this.loadTaskData();
|
this.loadTaskData();
|
||||||
};
|
};
|
||||||
|
|
||||||
closeAndSave = (e: Event): void => {
|
closeAndSave = (): void => {
|
||||||
e.preventDefault();
|
|
||||||
this.close();
|
this.close();
|
||||||
this.save();
|
this.save();
|
||||||
};
|
};
|
||||||
@@ -211,6 +216,8 @@ export default class TaskViewModel {
|
|||||||
public containingModel: TaskContainingPageViewModel,
|
public containingModel: TaskContainingPageViewModel,
|
||||||
public task: TaskFileContent,
|
public task: TaskFileContent,
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
// load
|
// load
|
||||||
this.loadAllData();
|
this.loadAllData();
|
||||||
|
|
||||||
@@ -218,6 +225,10 @@ export default class TaskViewModel {
|
|||||||
this.selectedVersionId.subscribeSilent((selectedVersionId) => {
|
this.selectedVersionId.subscribeSilent((selectedVersionId) => {
|
||||||
this.switchVersion(selectedVersionId);
|
this.switchVersion(selectedVersionId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// keystrokes
|
||||||
|
this.registerKeyStroke(CommonKeys.Apply, this.closeAndSave);
|
||||||
|
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.closeAndDiscard);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import StorageModel from "./Model/Global/storageModel";
|
|||||||
import StorageViewModel from "./ViewModel/Global/storageViewModel";
|
import StorageViewModel from "./ViewModel/Global/storageViewModel";
|
||||||
import v1Upgrader from "./Upgrader/v1";
|
import v1Upgrader from "./Upgrader/v1";
|
||||||
import { SettingsModal } from "./View/Modals/settingsModal";
|
import { SettingsModal } from "./View/Modals/settingsModal";
|
||||||
|
import HomeViewModel from "./ViewModel/Pages/homeViewModel";
|
||||||
|
|
||||||
// models
|
// models
|
||||||
const storageModel = new StorageModel();
|
const storageModel = new StorageModel();
|
||||||
@@ -56,6 +57,14 @@ const chatListViewModel = new ChatListViewModel(
|
|||||||
);
|
);
|
||||||
const fileTransferViewModel = new FileTransferViewModel(coreViewModel);
|
const fileTransferViewModel = new FileTransferViewModel(coreViewModel);
|
||||||
|
|
||||||
|
const homeViewModel = new HomeViewModel(
|
||||||
|
coreViewModel,
|
||||||
|
settingsViewModel,
|
||||||
|
fileTransferViewModel,
|
||||||
|
storageViewModel,
|
||||||
|
connectionViewModel,
|
||||||
|
);
|
||||||
|
|
||||||
// view
|
// view
|
||||||
chatListViewModel.selectedChat.subscribe(() => {
|
chatListViewModel.selectedChat.subscribe(() => {
|
||||||
document.body.toggleAttribute(
|
document.body.toggleAttribute(
|
||||||
|
|||||||
Reference in New Issue
Block a user