implement onboarding
This commit is contained in:
@@ -11,8 +11,8 @@ import ChatModel from "../../Model/Chat/chatModel";
|
||||
|
||||
export default class FileTransferViewModel extends Context {
|
||||
// state
|
||||
exitReception: ()=>void|undefined = undefined;
|
||||
|
||||
exitReception: () => void | undefined = undefined;
|
||||
|
||||
presentedModal: React.State<FileTransferModals | undefined> =
|
||||
new React.State<any>(undefined);
|
||||
|
||||
@@ -219,13 +219,13 @@ export default class FileTransferViewModel extends Context {
|
||||
};
|
||||
|
||||
correctTransferData = (): void => {
|
||||
if (this.exitReception != undefined) {
|
||||
this.presentedModal.value = undefined;
|
||||
this.exitReception();
|
||||
return;
|
||||
}
|
||||
this.showTransferDataInputModal()
|
||||
}
|
||||
if (this.exitReception != undefined) {
|
||||
this.presentedModal.value = undefined;
|
||||
this.exitReception();
|
||||
return;
|
||||
}
|
||||
this.showTransferDataInputModal();
|
||||
};
|
||||
|
||||
initiateTransfer = (): void => {
|
||||
this.presentedModal.value = FileTransferModals.TransferDisplay;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import SettingsViewModel from "./settingsViewModel";
|
||||
import { ChatPageTypes } from "../Chat/chatViewModel";
|
||||
import ChatListViewModel from "../Chat/chatListViewModel";
|
||||
import * as React from "../../react";
|
||||
import ChatModel, { ChatMessage } from "../../Model/Chat/chatModel";
|
||||
import SettingsViewModel from "./settingsViewModel";
|
||||
|
||||
export default class NotificationViewModel {
|
||||
// data
|
||||
@@ -16,7 +16,8 @@ export default class NotificationViewModel {
|
||||
showNotification = (message: ChatMessage): void => {
|
||||
if (this.seenMessageIds.has(message.fileId)) return;
|
||||
if (this.chatListViewModel.selectedChat.value == undefined) return;
|
||||
if (message.senderId == this.settingsViewModel.settingsModel.userid) return;
|
||||
if (message.senderId == this.settingsViewModel.settingsModel.userid)
|
||||
return;
|
||||
|
||||
const notification: Notification = this.createNotification(message);
|
||||
const currentChat =
|
||||
@@ -79,7 +80,10 @@ export default class NotificationViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(public chatListViewModel: ChatListViewModel, public settingsViewModel: SettingsViewModel) {}
|
||||
constructor(
|
||||
public chatListViewModel: ChatListViewModel,
|
||||
public settingsViewModel: SettingsViewModel,
|
||||
) {}
|
||||
|
||||
// util
|
||||
createNotification(message: ChatMessage): Notification {
|
||||
|
||||
@@ -1,52 +1,57 @@
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import * as React from "../../react";
|
||||
import FileTransferViewModel from "./fileTransferViewModel";
|
||||
import ConnectionViewModel from "./connectionViewModel";
|
||||
import SettingsViewModel from "./settingsViewModel";
|
||||
import FileTransferViewModel from "./fileTransferViewModel";
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import ConnectionViewModel from "./connectionViewModel";
|
||||
import * as React from "../../react";
|
||||
|
||||
export default class OnboardingViewModel {
|
||||
// state
|
||||
presentedModal: React.State<OnboardingModals | undefined> = new React.State<any>(undefined);
|
||||
presentedModal: React.State<OnboardingModals | undefined> =
|
||||
new React.State<any>(undefined);
|
||||
|
||||
// guards
|
||||
cannotTransfer: React.State<boolean> = React.createProxyState([this.connectionViewmodel.isConnected], ()=>!this.connectionViewmodel.isConnected.value)
|
||||
cannotTransfer: React.State<boolean> = React.createProxyState(
|
||||
[this.connectionViewmodel.isConnected],
|
||||
() => !this.connectionViewmodel.isConnected.value,
|
||||
);
|
||||
|
||||
// navigation
|
||||
// navigation
|
||||
open = (): void => {
|
||||
this.presentedModal.value = OnboardingModals.Connection;
|
||||
}
|
||||
this.presentedModal.value = OnboardingModals.Connection;
|
||||
};
|
||||
|
||||
showTransferOption = (): void => {
|
||||
this.presentedModal.value = OnboardingModals.TransferOrNew;
|
||||
}
|
||||
this.presentedModal.value = OnboardingModals.TransferOrNew;
|
||||
};
|
||||
|
||||
setupNew = (): void => {
|
||||
this.presentedModal.value = OnboardingModals.Name;
|
||||
}
|
||||
|
||||
this.presentedModal.value = OnboardingModals.Name;
|
||||
};
|
||||
|
||||
showTransferData = (): void => {
|
||||
this.presentedModal.value = OnboardingModals.Transfer;
|
||||
}
|
||||
this.presentedModal.value = OnboardingModals.Transfer;
|
||||
};
|
||||
|
||||
// methods
|
||||
transferData = (): void => {
|
||||
this.fileTransferViewModel.exitReception = ()=>this.showTransferData();
|
||||
this.fileTransferViewModel.prepareReceivingData();
|
||||
this.presentedModal.value = undefined;
|
||||
}
|
||||
this.fileTransferViewModel.exitReception = () =>
|
||||
this.showTransferData();
|
||||
this.fileTransferViewModel.prepareReceivingData();
|
||||
this.presentedModal.value = undefined;
|
||||
};
|
||||
|
||||
finish = (): void => {
|
||||
this.settingsViewModel.setName();
|
||||
this.presentedModal.value = undefined;
|
||||
}
|
||||
this.settingsViewModel.setName();
|
||||
this.presentedModal.value = undefined;
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public connectionViewmodel: ConnectionViewModel,
|
||||
public fileTransferViewModel: FileTransferViewModel,
|
||||
public settingsViewModel: SettingsViewModel,
|
||||
public connectionViewmodel: ConnectionViewModel,
|
||||
public fileTransferViewModel: FileTransferViewModel,
|
||||
public settingsViewModel: SettingsViewModel,
|
||||
) {
|
||||
if (this.settingsViewModel.settingsModel.username == "") this.open();
|
||||
if (this.settingsViewModel.settingsModel.username == "") this.open();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user