Skip to content

Commit

Permalink
[Calendar] close Calendar app instead of 404 with back action
Browse files Browse the repository at this point in the history
Close: #7229
  • Loading branch information
wrdhub committed Jul 24, 2024
1 parent ef2822a commit a3f2a8b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/calendar-app/calendarLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import type { HtmlSanitizer } from "../common/misc/HtmlSanitizer.js"
import { theme } from "../common/gui/theme.js"
import { CalendarSearchModel } from "./calendar/search/model/CalendarSearchModel.js"
import { SearchIndexStateInfo } from "../common/api/worker/search/SearchTypes.js"
import { CALENDAR_PREFIX } from "../common/misc/RouteChange.js"

assertMainOrNode()

Expand Down Expand Up @@ -577,7 +578,7 @@ class CalendarLocator {
const { WebInterWindowEventFacade } = await import("../common/native/main/WebInterWindowEventFacade.js")
const { WebAuthnFacadeSendDispatcher } = await import("../common/native/common/generatedipc/WebAuthnFacadeSendDispatcher.js")
const { createNativeInterfaces, createDesktopInterfaces } = await import("../common/native/main/NativeInterfaceFactory.js")
this.webMobileFacade = new WebMobileFacade(this.connectivityModel, this.mailModel)
this.webMobileFacade = new WebMobileFacade(this.connectivityModel, this.mailModel, CALENDAR_PREFIX)
this.nativeInterfaces = createNativeInterfaces(
this.webMobileFacade,
new WebDesktopFacade(this.logins, async () => this.native),
Expand Down
23 changes: 15 additions & 8 deletions src/common/native/main/WebMobileFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export class WebMobileFacade implements MobileFacade {

private isAppVisible: stream<boolean> = stream(false)

constructor(private readonly connectivityModel: WebsocketConnectivityModel, private readonly mailModel: MailModel) {}
constructor(
private readonly connectivityModel: WebsocketConnectivityModel,
private readonly mailModel: MailModel,
private readonly baseViewPrefix: string,
) {}

public getIsAppVisible(): stream<boolean> {
return this.isAppVisible
Expand Down Expand Up @@ -59,14 +63,17 @@ export class WebMobileFacade implements MobileFacade {
// current view can navigate back, a region column is focused (not main) and is in singleColumnLayout
viewSlider.focusPreviousColumn()
return true
} else if (
currentRoute.startsWith(CONTACTS_PREFIX) ||
currentRoute.startsWith(SETTINGS_PREFIX) ||
currentRoute.startsWith(SEARCH_PREFIX) ||
currentRoute.startsWith(CALENDAR_PREFIX)
) {
} else if (currentRoute.startsWith(CALENDAR_PREFIX)) {
if (this.baseViewPrefix === CALENDAR_PREFIX) {
// we are at the main view and want to exit the app
return false
} else {
m.route.set(this.baseViewPrefix)
return true
}
} else if (currentRoute.startsWith(CONTACTS_PREFIX) || currentRoute.startsWith(SETTINGS_PREFIX) || currentRoute.startsWith(SEARCH_PREFIX)) {
// go back to mail from other paths
m.route.set(MAIL_PREFIX)
m.route.set(this.baseViewPrefix)
return true
} else if (viewSlider && viewSlider.isFirstBackgroundColumnFocused()) {
// If the first background column is focused in mail view (showing a folder), move to inbox.
Expand Down
3 changes: 2 additions & 1 deletion src/mail-app/mailLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import { theme } from "../common/gui/theme.js"
import { SearchIndexStateInfo } from "../common/api/worker/search/SearchTypes.js"
import { MobilePaymentsFacade } from "../common/native/common/generatedipc/MobilePaymentsFacade.js"
import { AppStorePaymentPicker } from "../common/misc/AppStorePaymentPicker.js"
import { MAIL_PREFIX } from "../common/misc/RouteChange.js"

assertMainOrNode()

Expand Down Expand Up @@ -693,7 +694,7 @@ class MailLocator {
const { createNativeInterfaces, createDesktopInterfaces } = await import("../common/native/main/NativeInterfaceFactory.js")
const { parseContacts } = await import("./contacts/ContactImporter.js")

this.webMobileFacade = new WebMobileFacade(this.connectivityModel, this.mailModel)
this.webMobileFacade = new WebMobileFacade(this.connectivityModel, this.mailModel, MAIL_PREFIX)
this.nativeInterfaces = createNativeInterfaces(
this.webMobileFacade,
new WebDesktopFacade(this.logins, async () => this.native),
Expand Down

0 comments on commit a3f2a8b

Please sign in to comment.