correct type issues
This commit is contained in:
Binary file not shown.
@@ -9,7 +9,7 @@ import ConnectionModel from "../../Model/Global/connectionModel";
|
||||
import ChatListModel from "../../Model/Chat/chatListModel";
|
||||
|
||||
export default class CoreViewModel {
|
||||
readonly BUILD = "Build 26.09.06.A";
|
||||
readonly BUILD = "Build 26.09.09.A";
|
||||
|
||||
translations: Translations;
|
||||
|
||||
@@ -40,7 +40,8 @@ export default class CoreViewModel {
|
||||
return;
|
||||
|
||||
while (this.contexts.length > 0) {
|
||||
const currentContext: Context = this.context;
|
||||
const currentContext: Context|undefined= this.context;
|
||||
if (!currentContext) return;
|
||||
currentContext.handleContextClose(fromHistoryEvent);
|
||||
this.contextStack.delete(currentContext.contextId);
|
||||
if (currentContext.contextId == contextId) break;
|
||||
@@ -53,7 +54,7 @@ export default class CoreViewModel {
|
||||
const contexts: Context[] = this.contexts;
|
||||
while (contexts.length > 0) {
|
||||
const currentContext: Context | undefined = contexts.pop();
|
||||
if (!currentContext) contexts;
|
||||
if (!currentContext) return;
|
||||
const isHandled: boolean = currentContext.handleKeystroke(e);
|
||||
if (isHandled == true) break;
|
||||
}
|
||||
@@ -102,6 +103,7 @@ export default class CoreViewModel {
|
||||
document.body.addEventListener("keydown", this.handleKeyDown);
|
||||
|
||||
window.onpopstate = () => {
|
||||
if (!this.context) return;
|
||||
this.closeContext(this.context.contextId, true);
|
||||
};
|
||||
|
||||
@@ -142,7 +144,6 @@ export class Context {
|
||||
}
|
||||
|
||||
export class ContextHost<T> extends Context {
|
||||
coreViewModel: CoreViewModel;
|
||||
contexts = new Map<T, Context>();
|
||||
currentContext = new React.State<Context | undefined>(undefined);
|
||||
|
||||
@@ -169,8 +170,10 @@ export class ContextHost<T> extends Context {
|
||||
updateContexts = (): void => {
|
||||
if (this.isOpen == false) return;
|
||||
|
||||
const selection = this.contextSelection;
|
||||
if (!selection) return;
|
||||
const selectedContext: Context | undefined = this.contexts.get(
|
||||
this.contextSelection,
|
||||
selection
|
||||
);
|
||||
if (!selectedContext) return;
|
||||
if (selectedContext != this.currentContext.value) {
|
||||
@@ -180,4 +183,8 @@ export class ContextHost<T> extends Context {
|
||||
this.coreViewModel.context = selectedContext;
|
||||
this.currentContext.value = selectedContext;
|
||||
};
|
||||
|
||||
constructor(contextDebugDescription: string, public coreViewModel: CoreViewModel) {
|
||||
super(contextDebugDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export default class FileTransferViewModel extends Context {
|
||||
exportKey: React.State<string> = new React.State("");
|
||||
exportKeyConfirmation: React.State<string> = new React.State("");
|
||||
|
||||
importedFile: React.State<File | undefined> = new React.State(undefined);
|
||||
importedFile: React.State<File | undefined> = new React.State<File | undefined>(undefined);
|
||||
importedFileString: React.State<string> = new React.State("");
|
||||
importKey: React.State<string> = new React.State("");
|
||||
isImportKeyCorrect: React.State<boolean> = new React.State(true);
|
||||
@@ -158,6 +158,7 @@ export default class FileTransferViewModel extends Context {
|
||||
if (!input) return;
|
||||
if (!(input instanceof HTMLInputElement)) return;
|
||||
|
||||
if (!input.files) return;
|
||||
const file = input.files[0];
|
||||
this.importedFile.value = file;
|
||||
};
|
||||
@@ -170,6 +171,7 @@ export default class FileTransferViewModel extends Context {
|
||||
reader.readAsText(file, "utf8");
|
||||
reader.onload = () => {
|
||||
const result = reader.result;
|
||||
if (!result) return;
|
||||
this.importedFileString.value = result.toString();
|
||||
this.showImportDecryptDataModal();
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ export default class NotificationViewModel {
|
||||
};
|
||||
|
||||
openNotification = () => {
|
||||
const notification: Notification = this.marquee.value;
|
||||
const notification: Notification|undefined = this.marquee.value;
|
||||
if (notification == undefined) return;
|
||||
|
||||
const chat = [
|
||||
@@ -44,6 +44,7 @@ export default class NotificationViewModel {
|
||||
(chat) =>
|
||||
chat.chatModel.unwrappedPrimaryChannel == notification.chat,
|
||||
);
|
||||
if (!chat) return;
|
||||
chat.open();
|
||||
chat.openPage(ChatPageTypes.Messages);
|
||||
};
|
||||
@@ -55,7 +56,8 @@ export default class NotificationViewModel {
|
||||
return this.stopLoop();
|
||||
}
|
||||
|
||||
const notification: Notification = this.messagesInMarquee.shift();
|
||||
const notification: Notification|undefined = this.messagesInMarquee.shift();
|
||||
if (!notification) return;
|
||||
this.seenMessageIds.delete(notification.messageId);
|
||||
this.marquee.value = notification;
|
||||
};
|
||||
|
||||
@@ -9,14 +9,14 @@ export default class SettingsViewModel extends Context {
|
||||
usernameInput: React.State<string> = new React.State("");
|
||||
isShowingSettingsModal: React.State<boolean> = new React.State(false);
|
||||
selectedModalPage: React.State<SettingsModalPages | undefined> =
|
||||
new React.State(undefined);
|
||||
new React.State<SettingsModalPages | undefined>(undefined);
|
||||
requiresReload = new React.State<boolean>(false);
|
||||
|
||||
firstDayOfWeek: React.State<string> = new React.State("0");
|
||||
language: React.State<Languages | string> = new React.State(
|
||||
language: React.State<Languages | string> = new React.State<Languages | string>(
|
||||
Languages.English,
|
||||
);
|
||||
theme: React.State<ThemeSettings | string> = new React.State(
|
||||
theme: React.State<ThemeSettings | string> = new React.State<ThemeSettings | string>(
|
||||
ThemeSettings.System,
|
||||
);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export default class StorageViewModel extends Context {
|
||||
const path: string[] = StorageModel.stringToPathComponents(
|
||||
this.selectedPath.value,
|
||||
);
|
||||
const content: string | undefined =
|
||||
const content: string | null =
|
||||
this.coreViewModel.storageModel.read(path);
|
||||
return (
|
||||
(content ?? this.coreViewModel.translations.storage.notAFile) ||
|
||||
|
||||
Reference in New Issue
Block a user