From 7939185087eb36511d71f7e0d02b3f9f874a5aaa Mon Sep 17 00:00:00 2001 From: ivk Date: Wed, 4 Dec 2024 12:00:00 +0100 Subject: [PATCH] Refactor WebMobileFacade to delegate to MailView more We do not need to parse or manipulate URLs directly since MailView can use MailViewModel. --- src/calendar-app/calendarLocator.ts | 2 +- src/common/native/main/WebMobileFacade.ts | 16 +--------------- src/mail-app/mail/view/MailView.ts | 13 +++++++++++-- src/mail-app/mailLocator.ts | 19 +------------------ 4 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/calendar-app/calendarLocator.ts b/src/calendar-app/calendarLocator.ts index 0e9ca49d6d2c..6535d454428c 100644 --- a/src/calendar-app/calendarLocator.ts +++ b/src/calendar-app/calendarLocator.ts @@ -640,7 +640,7 @@ class CalendarLocator { const { createNativeInterfaces, createDesktopInterfaces } = await import("../common/native/main/NativeInterfaceFactory.js") const { OpenCalendarHandler } = await import("../common/native/main/OpenCalendarHandler.js") const openCalendarHandler = new OpenCalendarHandler(this.logins) - this.webMobileFacade = new WebMobileFacade(this.connectivityModel, this.mailboxModel, CALENDAR_PREFIX) + this.webMobileFacade = new WebMobileFacade(this.connectivityModel, CALENDAR_PREFIX) this.nativeInterfaces = createNativeInterfaces( this.webMobileFacade, new WebDesktopFacade(this.logins, async () => this.native), diff --git a/src/common/native/main/WebMobileFacade.ts b/src/common/native/main/WebMobileFacade.ts index 77bc51fa5334..d298231ae2b5 100644 --- a/src/common/native/main/WebMobileFacade.ts +++ b/src/common/native/main/WebMobileFacade.ts @@ -23,12 +23,7 @@ export class WebMobileFacade implements MobileFacade { private isAppVisible: stream = stream(false) - constructor( - private readonly connectivityModel: WebsocketConnectivityModel, - private readonly mailboxModel: MailboxModel, - private readonly baseViewPrefix: string, - private readonly mailBackNewRoute?: (currentRoute: string) => Promise, - ) {} + constructor(private readonly connectivityModel: WebsocketConnectivityModel, private readonly baseViewPrefix: string) {} public getIsAppVisible(): stream { return this.isAppVisible @@ -84,15 +79,6 @@ export class WebMobileFacade implements MobileFacade { // go back to mail or calendar from other paths m.route.set(this.baseViewPrefix) return true - } else if (viewSlider && viewSlider.isFirstBackgroundColumnFocused()) { - if (currentRoute.startsWith(MAIL_PREFIX) && this.mailBackNewRoute) { - const newRoute = await this.mailBackNewRoute(currentRoute) - if (newRoute) { - m.route.set(newRoute) - return true - } - } - return false } else { return false } diff --git a/src/mail-app/mail/view/MailView.ts b/src/mail-app/mail/view/MailView.ts index d0c7e937d755..f104cb3563c7 100644 --- a/src/mail-app/mail/view/MailView.ts +++ b/src/mail-app/mail/view/MailView.ts @@ -3,7 +3,7 @@ import { ViewSlider } from "../../../common/gui/nav/ViewSlider.js" import { ColumnType, ViewColumn } from "../../../common/gui/base/ViewColumn" import { lang } from "../../../common/misc/LanguageViewModel" import { Dialog } from "../../../common/gui/base/Dialog" -import { FeatureType, Keys, MailSetKind } from "../../../common/api/common/TutanotaConstants" +import { FeatureType, getMailFolderType, Keys, MailSetKind } from "../../../common/api/common/TutanotaConstants" import { AppHeaderAttrs, Header } from "../../../common/gui/Header.js" import type { Mail, MailBox, MailFolder } from "../../../common/api/entities/tutanota/TypeRefs.js" import { noOp, ofClass } from "@tutao/tutanota-utils" @@ -407,8 +407,17 @@ export class MailView extends BaseTopLevelView implements TopLevelView { - // If the first background column is focused in mail view (showing a folder), move to inbox. - // If in inbox already, quit - const parts = currentRoute.split("/").filter((part) => part !== "") - - if (parts.length > 1) { - const selectedMailListId = parts[1] - const [mailboxDetail] = await this.mailboxModel.getMailboxDetails() - const folders = await this.mailModel.getMailboxFoldersForId(assertNotNull(mailboxDetail.mailbox.folders)._id) - const inboxFolderId = getElementId(assertSystemFolderOfType(folders, MailSetKind.INBOX)) - - if (inboxFolderId !== selectedMailListId) { - return MAIL_PREFIX + "/" + inboxFolderId - } - } - - return null - }) + this.webMobileFacade = new WebMobileFacade(this.connectivityModel, MAIL_PREFIX) this.nativeInterfaces = createNativeInterfaces( this.webMobileFacade,