move translations to CoreVM, move models to CoreVM for sentralization
This commit is contained in:
@@ -11,8 +11,6 @@ import ConnectionViewModel from "../Global/connectionViewModel";
|
||||
import NotificationViewModel from "../Global/notificationViewModel";
|
||||
|
||||
export default class ChatListViewModel {
|
||||
storageModel: StorageModel;
|
||||
chatListModel: ChatListModel;
|
||||
settingsViewModel: SettingsViewModel;
|
||||
notificationViewModel: NotificationViewModel;
|
||||
connectionViewModel: ConnectionViewModel;
|
||||
@@ -39,9 +37,10 @@ export default class ChatListViewModel {
|
||||
|
||||
// methods
|
||||
createChat = (): void => {
|
||||
const chatModel: ChatModel = this.chatListModel.createChat(
|
||||
this.newChatPrimaryChannel.value,
|
||||
);
|
||||
const chatModel: ChatModel =
|
||||
this.coreViewModel.chatListModel.createChat(
|
||||
this.newChatPrimaryChannel.value,
|
||||
);
|
||||
this.newChatPrimaryChannel.value = "";
|
||||
|
||||
const chatViewModel: ChatViewModel =
|
||||
@@ -55,14 +54,13 @@ export default class ChatListViewModel {
|
||||
};
|
||||
|
||||
untrackChat = (chatViewModel: ChatViewModel): void => {
|
||||
this.chatListModel.untrackChat(chatViewModel.chatModel);
|
||||
this.coreViewModel.chatListModel.untrackChat(chatViewModel.chatModel);
|
||||
this.chatViewModels.remove(chatViewModel);
|
||||
};
|
||||
|
||||
createChatViewModel = (chatModel: ChatModel): ChatViewModel => {
|
||||
return new ChatViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
chatModel,
|
||||
this.settingsViewModel,
|
||||
this.notificationViewModel,
|
||||
@@ -91,7 +89,7 @@ export default class ChatListViewModel {
|
||||
// load
|
||||
loadChats = (): void => {
|
||||
this.chatViewModels.clear();
|
||||
for (const chatModel of this.chatListModel.chatModels.values()) {
|
||||
for (const chatModel of this.coreViewModel.chatListModel.chatModels.values()) {
|
||||
const chatViewModel = this.createChatViewModel(chatModel);
|
||||
this.trackChat(chatViewModel);
|
||||
}
|
||||
@@ -101,13 +99,9 @@ export default class ChatListViewModel {
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
chatListModel: ChatListModel,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
connectionViewModel: ConnectionViewModel,
|
||||
) {
|
||||
this.storageModel = storageModel;
|
||||
this.chatListModel = chatListModel;
|
||||
this.settingsViewModel = settingsViewModel;
|
||||
this.notificationViewModel = new NotificationViewModel(this);
|
||||
this.connectionViewModel = connectionViewModel;
|
||||
|
||||
@@ -20,13 +20,12 @@ import MessagePageViewModel from "../Pages/messagePageViewModel";
|
||||
import SettingsPageViewModel from "../Pages/settingsPageViewModel";
|
||||
import SettingsViewModel from "../Global/settingsViewModel";
|
||||
import TaskPageViewModel from "../Pages/taskPageViewModel";
|
||||
import { translations } from "../../View/translations";
|
||||
import ConnectionViewModel from "../Global/connectionViewModel";
|
||||
import NotificationViewModel from "../Global/notificationViewModel";
|
||||
|
||||
export default class ChatViewModel {
|
||||
chatModel: ChatModel;
|
||||
storageModel: StorageModel;
|
||||
|
||||
settingsViewModel: SettingsViewModel;
|
||||
notificationViewModel: NotificationViewModel;
|
||||
connectionViewModel: ConnectionViewModel;
|
||||
@@ -84,13 +83,14 @@ export default class ChatViewModel {
|
||||
StorageModelSubPaths.Chat,
|
||||
filePaths.chat.lastUsedPage(this.chatModel.id),
|
||||
);
|
||||
const lastUsedPage: string | null = this.storageModel.read(path);
|
||||
const lastUsedPage: string | null =
|
||||
this.coreViewModel.storageModel.read(path);
|
||||
if (lastUsedPage != null) {
|
||||
this.selectedPage.value = lastUsedPage as any;
|
||||
}
|
||||
|
||||
this.selectedPage.subscribeSilent((newPage) => {
|
||||
this.storageModel.write(path, newPage);
|
||||
this.coreViewModel.storageModel.write(path, newPage);
|
||||
this.resetColor();
|
||||
});
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export default class ChatViewModel {
|
||||
this.updateReadStatus();
|
||||
this.taskBoardSuggestions.set(CALENDAR_EVENT_BOARD_ID, [
|
||||
CALENDAR_EVENT_BOARD_ID,
|
||||
translations.chatPage.calendar.eventsBoard,
|
||||
this.coreViewModel.translations.chatPage.calendar.eventsBoard,
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -132,7 +132,6 @@ export default class ChatViewModel {
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
chatModel: ChatModel,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
notificationViewModel: NotificationViewModel,
|
||||
@@ -140,7 +139,6 @@ export default class ChatViewModel {
|
||||
chatListViewModel: ChatListViewModel,
|
||||
) {
|
||||
// models
|
||||
this.storageModel = storageModel;
|
||||
this.chatModel = chatModel;
|
||||
this.settingsViewModel = settingsViewModel;
|
||||
this.connectionViewModel = connectionViewModel;
|
||||
@@ -151,14 +149,12 @@ export default class ChatViewModel {
|
||||
this.calendarViewModel = new CalendarPageViewModel(
|
||||
coreViewModel,
|
||||
this,
|
||||
this.storageModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel,
|
||||
);
|
||||
this.taskPageViewModel = new TaskPageViewModel(
|
||||
this.coreViewModel,
|
||||
this,
|
||||
this.storageModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel,
|
||||
);
|
||||
this.messagePageViewModel = new MessagePageViewModel(
|
||||
|
||||
@@ -4,8 +4,6 @@ import ConnectionModel from "../../Model/Global/connectionModel";
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
|
||||
export default class ConnectionViewModel {
|
||||
connectionModel: ConnectionModel;
|
||||
|
||||
// state
|
||||
serverAddressInput: React.State<string> = new React.State("");
|
||||
isConnected: React.State<boolean> = new React.State(false);
|
||||
@@ -20,7 +18,7 @@ export default class ConnectionViewModel {
|
||||
() =>
|
||||
(this.isConnected.value == true &&
|
||||
this.serverAddressInput.value ==
|
||||
this.connectionModel.address) ||
|
||||
this.coreViewModel.connectionModel.address) ||
|
||||
this.serverAddressInput.value == "",
|
||||
);
|
||||
cannotDisonnect: React.State<boolean> = React.createProxyState(
|
||||
@@ -34,15 +32,22 @@ export default class ConnectionViewModel {
|
||||
|
||||
// handlers
|
||||
connectionChangeHandler = (): void => {
|
||||
this.isConnected.value = this.connectionModel.isConnected;
|
||||
this.isConnected.value = this.coreViewModel.connectionModel.isConnected;
|
||||
|
||||
if (this.connectionModel.isConnected == false) return;
|
||||
if (this.connectionModel.address == undefined) return;
|
||||
if (this.coreViewModel.connectionModel.isConnected == false) return;
|
||||
if (this.coreViewModel.connectionModel.address == undefined) return;
|
||||
|
||||
this.serverAddressInput.value = this.connectionModel.address;
|
||||
this.serverAddressInput.value =
|
||||
this.coreViewModel.connectionModel.address;
|
||||
|
||||
if (!this.previousAddresses.value.has(this.connectionModel.address)) {
|
||||
this.previousAddresses.add(this.connectionModel.address);
|
||||
if (
|
||||
!this.previousAddresses.value.has(
|
||||
this.coreViewModel.connectionModel.address,
|
||||
)
|
||||
) {
|
||||
this.previousAddresses.add(
|
||||
this.coreViewModel.connectionModel.address,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -53,15 +58,15 @@ export default class ConnectionViewModel {
|
||||
|
||||
connectToAddress = (address: string): void => {
|
||||
console.log(address);
|
||||
this.connectionModel.connect(address);
|
||||
this.coreViewModel.connectionModel.connect(address);
|
||||
};
|
||||
|
||||
disconnect = (): void => {
|
||||
this.connectionModel.disconnect();
|
||||
this.coreViewModel.connectionModel.disconnect();
|
||||
};
|
||||
|
||||
removePreviousAddress = (address: string): void => {
|
||||
this.connectionModel.removeAddress(address);
|
||||
this.coreViewModel.connectionModel.removeAddress(address);
|
||||
this.updatePreviousAddresses();
|
||||
};
|
||||
|
||||
@@ -76,18 +81,16 @@ export default class ConnectionViewModel {
|
||||
|
||||
updatePreviousAddresses = (): void => {
|
||||
this.previousAddresses.clear();
|
||||
this.previousAddresses.add(...this.connectionModel.addresses);
|
||||
this.previousAddresses.add(
|
||||
...this.coreViewModel.connectionModel.addresses,
|
||||
);
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
connectionModel: ConnectionModel,
|
||||
) {
|
||||
this.connectionModel = connectionModel;
|
||||
constructor(public coreViewModel: CoreViewModel) {
|
||||
this.updatePreviousAddresses();
|
||||
|
||||
connectionModel.connectionChangeHandlerManager.addHandler(
|
||||
coreViewModel.connectionModel.connectionChangeHandlerManager.addHandler(
|
||||
this.connectionChangeHandler,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import * as React from "bloatless-react";
|
||||
import SettingsModel from "../../Model/Global/settingsModel";
|
||||
import { allTranslations, Translations } from "../../View/translations";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import ConnectionModel from "../../Model/Global/connectionModel";
|
||||
import ChatListModel from "../../Model/Chat/chatListModel";
|
||||
import FileTransferModel from "../../Model/Global/fileTransferModel";
|
||||
|
||||
export default class CoreViewModel {
|
||||
readonly BUILD = "Build 26.04.08.C";
|
||||
readonly BUILD = "Build 26.04.09.A";
|
||||
|
||||
translations: Translations;
|
||||
|
||||
// DRAG & DROP
|
||||
draggedObject: React.State<any> = new React.State<any>(undefined);
|
||||
@@ -13,4 +21,16 @@ export default class CoreViewModel {
|
||||
|
||||
taskCategorySuggestions: React.ListState<string> = new React.ListState();
|
||||
taskStatusSuggestions: React.ListState<string> = new React.ListState();
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public storageModel: StorageModel,
|
||||
public settingsModel: SettingsModel,
|
||||
public connectionModel: ConnectionModel,
|
||||
public chatListModel: ChatListModel,
|
||||
public fileTransferModel: FileTransferModel,
|
||||
) {
|
||||
this.translations =
|
||||
allTranslations[settingsModel.language] || allTranslations.en;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,9 @@ import StorageModel, {
|
||||
|
||||
import ChatListModel from "../../Model/Chat/chatListModel";
|
||||
import ChatModel from "../../Model/Chat/chatModel";
|
||||
import { translations } from "../../View/translations";
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
|
||||
export default class FileTransferViewModel {
|
||||
fileTransferModel: FileTransferModel;
|
||||
chatListModel: ChatListModel;
|
||||
|
||||
// state
|
||||
presentedModal: React.State<FileTransferModals | undefined> =
|
||||
new React.State<any>(undefined);
|
||||
@@ -40,7 +37,7 @@ export default class FileTransferViewModel {
|
||||
filesSentText: React.State<string> = React.createProxyState(
|
||||
[this.filesSentCount],
|
||||
() =>
|
||||
translations.dataTransferModal.filesSentCount(
|
||||
this.coreViewModel.translations.dataTransferModal.filesSentCount(
|
||||
this.filesSentCount.value,
|
||||
),
|
||||
);
|
||||
@@ -53,7 +50,7 @@ export default class FileTransferViewModel {
|
||||
filesReceivedText: React.State<string> = React.createProxyState(
|
||||
[this.filesReceivedCount],
|
||||
() =>
|
||||
translations.dataTransferModal.filesReceivedCount(
|
||||
this.coreViewModel.translations.dataTransferModal.filesReceivedCount(
|
||||
this.filesReceivedCount.value,
|
||||
),
|
||||
);
|
||||
@@ -84,14 +81,16 @@ export default class FileTransferViewModel {
|
||||
|
||||
this.generalFileOptions.add(
|
||||
{
|
||||
label: translations.dataTransferModal.connectionData,
|
||||
label: this.coreViewModel.translations.dataTransferModal
|
||||
.connectionData,
|
||||
path: StorageModel.getPath(
|
||||
StorageModelSubPaths.ConnectionModel,
|
||||
filePaths.connectionModel.previousAddresses,
|
||||
),
|
||||
},
|
||||
{
|
||||
label: translations.dataTransferModal.settingsData,
|
||||
label: this.coreViewModel.translations.dataTransferModal
|
||||
.settingsData,
|
||||
path: StorageModel.getPath(
|
||||
StorageModelSubPaths.SettingsModel,
|
||||
[],
|
||||
@@ -99,7 +98,8 @@ export default class FileTransferViewModel {
|
||||
},
|
||||
);
|
||||
|
||||
const chatModels: Set<ChatModel> = this.chatListModel.chatModels;
|
||||
const chatModels: Set<ChatModel> =
|
||||
this.coreViewModel.chatListModel.chatModels;
|
||||
for (const chatModel of chatModels) {
|
||||
this.chatFileOptions.add({
|
||||
label: chatModel.info.primaryChannel,
|
||||
@@ -110,7 +110,7 @@ export default class FileTransferViewModel {
|
||||
|
||||
getTransferData = (): void => {
|
||||
const transferData: TransferData =
|
||||
this.fileTransferModel.generateTransferData();
|
||||
this.coreViewModel.fileTransferModel.generateTransferData();
|
||||
this.transferChannel.value = transferData.channel;
|
||||
this.transferKey.value = transferData.key;
|
||||
};
|
||||
@@ -128,7 +128,7 @@ export default class FileTransferViewModel {
|
||||
showTransferDataModal = (): void => {
|
||||
this.presentedModal.value = FileTransferModals.TransferDataDisplay;
|
||||
this.getTransferData();
|
||||
this.fileTransferModel.prepareToSend();
|
||||
this.coreViewModel.fileTransferModel.prepareToSend();
|
||||
};
|
||||
|
||||
initiateTransfer = (): void => {
|
||||
@@ -136,7 +136,7 @@ export default class FileTransferViewModel {
|
||||
this.didNotFinishSending.value = true;
|
||||
this.filePathsSent.clear();
|
||||
|
||||
this.fileTransferModel.sendFiles(
|
||||
this.coreViewModel.fileTransferModel.sendFiles(
|
||||
this.selectedPaths.value.values(),
|
||||
(path: string) => {
|
||||
console.log(path);
|
||||
@@ -159,7 +159,7 @@ export default class FileTransferViewModel {
|
||||
channel: this.receivingTransferChannel.value,
|
||||
key: this.receivingTransferKey.value,
|
||||
};
|
||||
this.fileTransferModel.prepareToReceive(transferData);
|
||||
this.coreViewModel.fileTransferModel.prepareToReceive(transferData);
|
||||
};
|
||||
|
||||
hideModal = (): void => {
|
||||
@@ -167,19 +167,13 @@ export default class FileTransferViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
fileTransferModel: FileTransferModel,
|
||||
chatListModel: ChatListModel,
|
||||
) {
|
||||
this.fileTransferModel = fileTransferModel;
|
||||
this.chatListModel = chatListModel;
|
||||
|
||||
this.fileTransferModel.fileHandlerManager.addHandler(
|
||||
constructor(public coreViewModel: CoreViewModel) {
|
||||
this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler(
|
||||
this.handleReceivedFile,
|
||||
);
|
||||
|
||||
this.fileTransferModel.readyToSendHandlerManager.addHandler(() =>
|
||||
this.initiateTransfer(),
|
||||
this.coreViewModel.fileTransferModel.readyToSendHandlerManager.addHandler(
|
||||
() => this.initiateTransfer(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,36 +2,40 @@ import * as React from "bloatless-react";
|
||||
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import SettingsModel from "../../Model/Global/settingsModel";
|
||||
import { Languages } from "../../View/translations";
|
||||
|
||||
export default class SettingsViewModel {
|
||||
settingsModel: SettingsModel;
|
||||
|
||||
// state
|
||||
username: React.State<string> = new React.State("");
|
||||
usernameInput: React.State<string> = new React.State("");
|
||||
firstDayOfWeekInput: React.State<string> = new React.State("0");
|
||||
isShowingSettingsModal: React.State<boolean> = new React.State(false);
|
||||
selectedModalPage: React.State<SettingsModalPages> = new React.State(
|
||||
SettingsModalPages.Appearance,
|
||||
);
|
||||
|
||||
firstDayOfWeek: React.State<string> = new React.State("0");
|
||||
language: React.State<Languages> = new React.State(Languages.English);
|
||||
|
||||
// guards
|
||||
cannotSetName: React.State<boolean> = React.createProxyState(
|
||||
[this.usernameInput],
|
||||
() =>
|
||||
this.usernameInput.value == "" ||
|
||||
this.usernameInput.value == this.settingsModel.username,
|
||||
this.usernameInput.value ==
|
||||
this.coreViewModel.settingsModel.username,
|
||||
);
|
||||
|
||||
// methods
|
||||
setName = (): void => {
|
||||
this.settingsModel.setName(this.usernameInput.value);
|
||||
this.username.value = this.settingsModel.username;
|
||||
this.coreViewModel.settingsModel.setName(this.usernameInput.value);
|
||||
this.username.value = this.coreViewModel.settingsModel.username;
|
||||
this.usernameInput.callSubscriptions();
|
||||
};
|
||||
|
||||
setFirstDayofWeek = (): void => {
|
||||
this.settingsModel.setFirstDayOfWeek(this.firstDayOfWeekInput.value);
|
||||
this.coreViewModel.settingsModel.setFirstDayOfWeek(
|
||||
this.firstDayOfWeek.value,
|
||||
);
|
||||
};
|
||||
|
||||
showSettingsModal = (): void => {
|
||||
@@ -47,18 +51,13 @@ export default class SettingsViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
settingsModel: SettingsModel,
|
||||
) {
|
||||
this.settingsModel = settingsModel;
|
||||
|
||||
this.username.value = settingsModel.username;
|
||||
this.usernameInput.value = settingsModel.username;
|
||||
this.firstDayOfWeekInput.value = settingsModel.firstDayOfWeek;
|
||||
constructor(public coreViewModel: CoreViewModel) {
|
||||
this.username.value = coreViewModel.settingsModel.username;
|
||||
this.usernameInput.value = coreViewModel.settingsModel.username;
|
||||
this.firstDayOfWeek.value = coreViewModel.settingsModel.firstDayOfWeek;
|
||||
|
||||
// subscriptions
|
||||
this.firstDayOfWeekInput.subscribe(this.setFirstDayofWeek);
|
||||
this.firstDayOfWeek.subscribe(this.setFirstDayofWeek);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,8 @@ import StorageModel, {
|
||||
} from "../../Model/Global/storageModel";
|
||||
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import { translations } from "../../View/translations";
|
||||
|
||||
export default class StorageViewModel {
|
||||
storageModel: StorageModel;
|
||||
|
||||
// state
|
||||
isShowingStorageModal: React.State<boolean> = new React.State(false);
|
||||
selectedPath: React.State<string> = new React.State(
|
||||
@@ -27,10 +24,10 @@ export default class StorageViewModel {
|
||||
const path = StorageModel.stringToPathComponents(
|
||||
this.selectedPath.value,
|
||||
);
|
||||
const content = this.storageModel.read(path);
|
||||
const content = this.coreViewModel.storageModel.read(path);
|
||||
return (
|
||||
(content ?? translations.storage.notAFile) ||
|
||||
translations.storage.contentEmpty
|
||||
(content ?? this.coreViewModel.translations.storage.notAFile) ||
|
||||
this.coreViewModel.translations.storage.contentEmpty
|
||||
);
|
||||
};
|
||||
|
||||
@@ -40,12 +37,12 @@ export default class StorageViewModel {
|
||||
);
|
||||
this.lastDeletedItemPath.value = this.selectedPath.value;
|
||||
|
||||
this.storageModel.removeRecursively(path);
|
||||
this.coreViewModel.storageModel.removeRecursively(path);
|
||||
this.didMakeChanges.value = true;
|
||||
};
|
||||
|
||||
removeJunk = (): void => {
|
||||
this.storageModel.removeJunk();
|
||||
this.coreViewModel.storageModel.removeJunk();
|
||||
this.selectedPath.value = PATH_COMPONENT_SEPARATOR;
|
||||
};
|
||||
|
||||
@@ -63,12 +60,7 @@ export default class StorageViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
) {
|
||||
this.storageModel = storageModel;
|
||||
|
||||
constructor(public coreViewModel: CoreViewModel) {
|
||||
this.selectedFileName = React.createProxyState(
|
||||
[this.selectedPath],
|
||||
() => StorageModel.getFileNameFromString(this.selectedPath.value),
|
||||
|
||||
@@ -15,7 +15,6 @@ import TaskPageViewModel from "./taskPageViewModel";
|
||||
import TaskViewModel from "./taskViewModel";
|
||||
|
||||
export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
storageModel: StorageModel;
|
||||
boardsAndTasksModel: BoardsAndTasksModel;
|
||||
|
||||
taskPageViewModel: TaskPageViewModel;
|
||||
@@ -104,12 +103,13 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
storeLastUsedView = (): void => {
|
||||
const path: string[] = this.getLastUsedBoardPath();
|
||||
const lastUsedView: string = this.selectedPage.value;
|
||||
this.storageModel.write(path, lastUsedView);
|
||||
this.coreViewModel.storageModel.write(path, lastUsedView);
|
||||
};
|
||||
|
||||
restoreLastUsedView = (): void => {
|
||||
const path: string[] = this.getLastUsedBoardPath();
|
||||
const lastUsedView: string | null = this.storageModel.read(path);
|
||||
const lastUsedView: string | null =
|
||||
this.coreViewModel.storageModel.read(path);
|
||||
if (lastUsedView == null) return;
|
||||
|
||||
this.selectedPage.value = lastUsedView as BoardPageTypes;
|
||||
@@ -120,7 +120,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
...this.getPreviousSearchesPath(),
|
||||
searchTerm,
|
||||
];
|
||||
this.storageModel.write(suggestionPath, "");
|
||||
this.coreViewModel.storageModel.write(suggestionPath, "");
|
||||
if (
|
||||
!this.coreViewModel.boardFilterStringSuggestions.value.has(
|
||||
searchTerm,
|
||||
@@ -130,7 +130,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
}
|
||||
|
||||
const lastSearchPath: string[] = this.getLastSearchPath();
|
||||
this.storageModel.write(lastSearchPath, searchTerm);
|
||||
this.coreViewModel.storageModel.write(lastSearchPath, searchTerm);
|
||||
};
|
||||
|
||||
// view
|
||||
@@ -224,14 +224,15 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
|
||||
loadSearchSuggestions = (): void => {
|
||||
const dirPath: string[] = this.getPreviousSearchesPath();
|
||||
const searches: string[] = this.storageModel.list(dirPath);
|
||||
const searches: string[] =
|
||||
this.coreViewModel.storageModel.list(dirPath);
|
||||
this.coreViewModel.boardFilterStringSuggestions.add(...searches);
|
||||
};
|
||||
|
||||
restoreSearch = (): void => {
|
||||
const lastSearchPath: string[] = this.getLastSearchPath();
|
||||
const lastSearch: string | null =
|
||||
this.storageModel.read(lastSearchPath);
|
||||
this.coreViewModel.storageModel.read(lastSearchPath);
|
||||
if (lastSearch != null) {
|
||||
this.searchViewModel.search(lastSearch);
|
||||
}
|
||||
@@ -247,7 +248,6 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
public chatViewModel: ChatViewModel,
|
||||
storageModel: StorageModel,
|
||||
boardsAndTasksModel: BoardsAndTasksModel,
|
||||
taskPageViewModel: TaskPageViewModel,
|
||||
boardInfo: BoardInfoFileContent,
|
||||
@@ -255,7 +255,6 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
super(coreViewModel, chatViewModel, boardsAndTasksModel);
|
||||
|
||||
// set
|
||||
this.storageModel = storageModel;
|
||||
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||
this.taskPageViewModel = taskPageViewModel;
|
||||
this.boardInfo = boardInfo;
|
||||
|
||||
@@ -14,7 +14,6 @@ import TaskViewModel from "./taskViewModel";
|
||||
export const CALENDAR_EVENT_BOARD_ID = "events";
|
||||
|
||||
export default class CalendarPageViewModel extends TaskContainingPageViewModel {
|
||||
storageModel: StorageModel;
|
||||
calendarModel: CalendarModel;
|
||||
boardsAndTasksModel: BoardsAndTasksModel;
|
||||
|
||||
@@ -189,13 +188,11 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
public chatViewModel: ChatViewModel,
|
||||
storageModel: StorageModel,
|
||||
calendarModel: CalendarModel,
|
||||
boardsAndTasksModel: BoardsAndTasksModel,
|
||||
) {
|
||||
super(coreViewModel, chatViewModel, boardsAndTasksModel);
|
||||
|
||||
this.storageModel = storageModel;
|
||||
this.calendarModel = calendarModel;
|
||||
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import { IndexManager } from "../../Model/Utility/utility";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
|
||||
export default class TaskPageViewModel {
|
||||
storageModel: StorageModel;
|
||||
boardsAndTasksModel: BoardsAndTasksModel;
|
||||
|
||||
// data
|
||||
@@ -82,7 +81,6 @@ export default class TaskPageViewModel {
|
||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||
this.coreViewModel,
|
||||
this.chatViewModel,
|
||||
this.storageModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
boardInfo,
|
||||
@@ -120,12 +118,13 @@ export default class TaskPageViewModel {
|
||||
storeLastUsedBoard = (): void => {
|
||||
const path: string[] = this.getLastUsedBoardPath();
|
||||
const lastUsedBoardId: string = this.selectedBoardId.value ?? "";
|
||||
this.storageModel.write(path, lastUsedBoardId);
|
||||
this.coreViewModel.storageModel.write(path, lastUsedBoardId);
|
||||
};
|
||||
|
||||
openLastUsedBoard = (): void => {
|
||||
const path: string[] = this.getLastUsedBoardPath();
|
||||
const lastUsedBoardId: string | null = this.storageModel.read(path);
|
||||
const lastUsedBoardId: string | null =
|
||||
this.coreViewModel.storageModel.read(path);
|
||||
if (lastUsedBoardId == null) return;
|
||||
|
||||
const boardViewModel: BoardViewModel | undefined =
|
||||
@@ -156,10 +155,8 @@ export default class TaskPageViewModel {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
public chatViewModel: ChatViewModel,
|
||||
storageModel: StorageModel,
|
||||
boardModel: BoardsAndTasksModel,
|
||||
) {
|
||||
this.storageModel = storageModel;
|
||||
this.boardsAndTasksModel = boardModel;
|
||||
|
||||
this.chatViewModel = chatViewModel;
|
||||
|
||||
Reference in New Issue
Block a user