feat: handle basic routes (#1784)
This commit is contained in:
@@ -19,25 +19,25 @@ import {
|
||||
WebApplicationInterface,
|
||||
MobileDeviceInterface,
|
||||
MobileUnlockTiming,
|
||||
InternalEventBus,
|
||||
} from '@standardnotes/snjs'
|
||||
import { makeObservable, observable } from 'mobx'
|
||||
import { PanelResizedData } from '@/Types/PanelResizedData'
|
||||
import { isDesktopApplication } from '@/Utils'
|
||||
import { DesktopManager } from './Device/DesktopManager'
|
||||
import { ArchiveManager, AutolockService, IOService, WebAlertService, ThemeManager } from '@standardnotes/ui-services'
|
||||
import {
|
||||
ArchiveManager,
|
||||
AutolockService,
|
||||
IOService,
|
||||
RouteService,
|
||||
ThemeManager,
|
||||
WebAlertService,
|
||||
} from '@standardnotes/ui-services'
|
||||
import { MobileWebReceiver } from './MobileWebReceiver'
|
||||
import { AndroidBackHandler } from '@/NativeMobileWeb/AndroidBackHandler'
|
||||
import { PrefDefaults } from '@/Constants/PrefDefaults'
|
||||
import { setViewportHeightWithFallback } from '@/App'
|
||||
|
||||
type WebServices = {
|
||||
viewControllerManager: ViewControllerManager
|
||||
desktopService?: DesktopManager
|
||||
autolockService?: AutolockService
|
||||
archiveService: ArchiveManager
|
||||
themeService: ThemeManager
|
||||
io: IOService
|
||||
}
|
||||
import { setViewportHeightWithFallback } from '@/setViewportHeightWithFallback'
|
||||
import { WebServices } from './WebServices'
|
||||
|
||||
export type WebEventObserver = (event: WebAppEvent, data?: unknown) => void
|
||||
|
||||
@@ -49,6 +49,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
private onVisibilityChange: () => void
|
||||
private mobileWebReceiver?: MobileWebReceiver
|
||||
private androidBackHandler?: AndroidBackHandler
|
||||
public readonly routeService: RouteService
|
||||
|
||||
constructor(
|
||||
deviceInterface: WebOrDesktopDevice,
|
||||
@@ -75,8 +76,25 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
})
|
||||
|
||||
deviceInterface.setApplication(this)
|
||||
const internalEventBus = new InternalEventBus()
|
||||
|
||||
this.itemControllerGroup = new ItemGroupController(this)
|
||||
this.iconsController = new IconsController()
|
||||
this.routeService = new RouteService(this, internalEventBus)
|
||||
|
||||
const viewControllerManager = new ViewControllerManager(this, deviceInterface)
|
||||
const archiveService = new ArchiveManager(this)
|
||||
const io = new IOService(platform === Platform.MacWeb || platform === Platform.MacDesktop)
|
||||
const themeService = new ThemeManager(this, internalEventBus)
|
||||
|
||||
this.setWebServices({
|
||||
viewControllerManager,
|
||||
archiveService,
|
||||
desktopService: isDesktopDevice(deviceInterface) ? new DesktopManager(this, deviceInterface) : undefined,
|
||||
io,
|
||||
autolockService: this.isNativeMobileWeb() ? undefined : new AutolockService(this, internalEventBus),
|
||||
themeService,
|
||||
})
|
||||
|
||||
if (this.isNativeMobileWeb()) {
|
||||
this.mobileWebReceiver = new MobileWebReceiver(this)
|
||||
@@ -121,6 +139,9 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
||||
;(this.itemControllerGroup as unknown) = undefined
|
||||
;(this.mobileWebReceiver as unknown) = undefined
|
||||
|
||||
this.routeService.deinit()
|
||||
;(this.routeService as unknown) = undefined
|
||||
|
||||
this.webEventObservers.length = 0
|
||||
|
||||
document.removeEventListener('visibilitychange', this.onVisibilityChange)
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import { WebApplication } from './Application'
|
||||
import {
|
||||
ApplicationDescriptor,
|
||||
SNApplicationGroup,
|
||||
Platform,
|
||||
InternalEventBus,
|
||||
isDesktopDevice,
|
||||
} from '@standardnotes/snjs'
|
||||
import { ArchiveManager, IOService, AutolockService, ThemeManager } from '@standardnotes/ui-services'
|
||||
|
||||
import { ViewControllerManager } from '@/Controllers/ViewControllerManager'
|
||||
import { ApplicationDescriptor, SNApplicationGroup } from '@standardnotes/snjs'
|
||||
import { getPlatform, isDesktopApplication } from '@/Utils'
|
||||
import { WebOrDesktopDevice } from '@/Application/Device/WebOrDesktopDevice'
|
||||
import { DesktopManager } from './Device/DesktopManager'
|
||||
|
||||
const createApplication = (
|
||||
descriptor: ApplicationDescriptor,
|
||||
@@ -30,21 +20,6 @@ const createApplication = (
|
||||
webSocketUrl,
|
||||
)
|
||||
|
||||
const viewControllerManager = new ViewControllerManager(application, device)
|
||||
const archiveService = new ArchiveManager(application)
|
||||
const io = new IOService(platform === Platform.MacWeb || platform === Platform.MacDesktop)
|
||||
const internalEventBus = new InternalEventBus()
|
||||
const themeService = new ThemeManager(application, internalEventBus)
|
||||
|
||||
application.setWebServices({
|
||||
viewControllerManager,
|
||||
archiveService,
|
||||
desktopService: isDesktopDevice(device) ? new DesktopManager(application, device) : undefined,
|
||||
io,
|
||||
autolockService: application.isNativeMobileWeb() ? undefined : new AutolockService(application, internalEventBus),
|
||||
themeService,
|
||||
})
|
||||
|
||||
return application
|
||||
}
|
||||
|
||||
|
||||
12
packages/web/src/javascripts/Application/WebServices.ts
Normal file
12
packages/web/src/javascripts/Application/WebServices.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ViewControllerManager } from '@/Controllers/ViewControllerManager'
|
||||
import { DesktopManager } from './Device/DesktopManager'
|
||||
import { ArchiveManager, AutolockService, IOService, ThemeManager } from '@standardnotes/ui-services'
|
||||
|
||||
export type WebServices = {
|
||||
viewControllerManager: ViewControllerManager
|
||||
desktopService?: DesktopManager
|
||||
autolockService?: AutolockService
|
||||
archiveService: ArchiveManager
|
||||
themeService: ThemeManager
|
||||
io: IOService
|
||||
}
|
||||
Reference in New Issue
Block a user