diff --git a/src-main/record-at-app-launch.ts b/src-main/record-at-app-launch.ts index deea24fb..14cd0801 100644 --- a/src-main/record-at-app-launch.ts +++ b/src-main/record-at-app-launch.ts @@ -3,12 +3,14 @@ import { app, screen } from 'electron'; import { Analytics } from '../src-shared/analytics/analytics'; import { DateTimeFormat } from '../src-shared/date-time/date-time-format'; import { DevOrProd } from '../src-shared/dev-or-prod/dev-or-prod'; +import { IpcConstants } from '../src-shared/ipc/ipc-constants'; import { Logger } from '../src-shared/log/logger'; import { toLoggableString } from '../src-shared/log/to-loggable-string'; import { UserDataStorage } from '../src-shared/user-data-storage/user-data-storage'; import { UserDataStoragePath } from '../src-shared/user-data-storage/user-data-stroage-path'; import { currentUserSettings } from '../src-shared/user-settings/user-settings'; import { commandLineOptionsValue } from './command-line-options/command-line-options-value'; +import { mainWindow } from './electron-main'; import { LaunchInfo } from './launch-info'; import { recordWindowState } from './window-config'; @@ -105,6 +107,10 @@ const recordSideBarMenuSortDirection = () => { Analytics.trackEvent('Sidebar Menu', `[Sort] Direction at App Launch`, `Sort Direction at App Launch: ${sortDirection}`); }; +const finishRecordAtAppLaunch = () => { + mainWindow.webContents.send(IpcConstants.RecordAtAppLaunch.Finished); +}; + export const recordAtAppLaunch = () => { recordAppLaunch(); recordCommandLineOptions(); @@ -128,4 +134,6 @@ export const recordAtAppLaunch = () => { recordSidebarMenuSortKey(); recordSideBarMenuSortDirection(); + + finishRecordAtAppLaunch(); }; diff --git a/src-shared/ipc/ipc-constants.ts b/src-shared/ipc/ipc-constants.ts index cd1065db..7bc41d67 100644 --- a/src-shared/ipc/ipc-constants.ts +++ b/src-shared/ipc/ipc-constants.ts @@ -3,6 +3,10 @@ export namespace IpcConstants { export const Get = 'ipc-constants-get-command-line-options'; } + export namespace RecordAtAppLaunch { + export const Finished = 'ipc-constants-record-at-app-launch-finished'; + } + export namespace AboutBox { export const Name = 'ipc-constants-show-about-box'; } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 90479182..9accd3e1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,6 +6,7 @@ import { PlmInternalRenderer, PlmInternalRendererAboutBox, PlmInternalRendererPhotoSelection, + PlmInternalRendererRecordAtAppLaunch, PlmInternalRendererSettingsDialog, PlmInternalRendererWelcomeDialog } from '../global-variables/global-variable-for-internal-use-in-renderer'; @@ -36,6 +37,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { public ngOnInit(): void { window.plmInternalRenderer = window.plmInternalRenderer || new PlmInternalRenderer(); + window.plmInternalRenderer.recordAtAppLaunch = window.plmInternalRenderer.recordAtAppLaunch || new PlmInternalRendererRecordAtAppLaunch(); + window.plmInternalRenderer.recordAtAppLaunch.handleRecordAtAppLaunchFinished = () => this.handleRecordAtAppLaunchFinished(); + window.plmInternalRenderer.aboutBox = window.plmInternalRenderer.aboutBox || new PlmInternalRendererAboutBox(); window.plmInternalRenderer.aboutBox.showAboutBox = () => this.showAboutBox(); @@ -55,18 +59,21 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { public ngAfterViewInit(): void { this.welcomeDialogAtAppLaunchService.showWelcomeDialogIfUserHasNotClickedOk(); - - // noinspection JSIgnoredPromiseFromCall - this.openAfterLaunchService.openAfterLaunchIfNeeded(); } public ngOnDestroy(): void { + window.plmInternalRenderer.recordAtAppLaunch.handleRecordAtAppLaunchFinished = null; window.plmInternalRenderer.aboutBox.showAboutBox = null; window.plmInternalRenderer.settingsDialog.showSettingsDialog = null; window.plmInternalRenderer.welcomeDialog.showWelcomeDialog = null; window.plmInternalRenderer.photoSelection = null; } + private handleRecordAtAppLaunchFinished() { + // noinspection JSIgnoredPromiseFromCall + this.openAfterLaunchService.openAfterLaunchIfNeeded(); + } + public showAboutBox(): void { this.ngZone.run(() => { this.dialog.open(AboutBoxComponent, { diff --git a/src/global-variables/global-variable-for-internal-use-in-renderer.ts b/src/global-variables/global-variable-for-internal-use-in-renderer.ts index 95833a58..3d6cd7c9 100644 --- a/src/global-variables/global-variable-for-internal-use-in-renderer.ts +++ b/src/global-variables/global-variable-for-internal-use-in-renderer.ts @@ -1,4 +1,5 @@ export class PlmInternalRenderer implements IPlmInternalRenderer { + public recordAtAppLaunch: PlmInternalRendererRecordAtAppLaunch; public aboutBox: PlmInternalRendererAboutBox; public settingsDialog: PlmInternalRendererSettingsDialog; public welcomeDialog: PlmInternalRendererWelcomeDialog; @@ -6,6 +7,10 @@ export class PlmInternalRenderer implements IPlmInternalRenderer { public photoSelection: IPlmInternalRendererPhotoSelection; } +export class PlmInternalRendererRecordAtAppLaunch implements IPlmInternalRendererRecordAtAppLaunch { + public handleRecordAtAppLaunchFinished: () => void; +} + export class PlmInternalRendererAboutBox implements AboutBoxShowable { public showAboutBox: () => void; } diff --git a/src/ipc-renderer-setup/ipc-renderer-all-setup.ts b/src/ipc-renderer-setup/ipc-renderer-all-setup.ts index 70fb8b2e..dadd4cec 100644 --- a/src/ipc-renderer-setup/ipc-renderer-all-setup.ts +++ b/src/ipc-renderer-setup/ipc-renderer-all-setup.ts @@ -2,4 +2,5 @@ import './ipc-renderer-about-box-setup'; import './ipc-renderer-manage-settings-setup'; import './ipc-renderer-map-setup'; import './ipc-renderer-photo-selection-setup'; +import './ipc-renderer-record-at-app-launch-setup'; import './ipc-renderer-welcome-dialog-setup'; diff --git a/src/ipc-renderer-setup/ipc-renderer-record-at-app-launch-setup.ts b/src/ipc-renderer-setup/ipc-renderer-record-at-app-launch-setup.ts new file mode 100644 index 00000000..d529a30a --- /dev/null +++ b/src/ipc-renderer-setup/ipc-renderer-record-at-app-launch-setup.ts @@ -0,0 +1,10 @@ +import { IpcConstants } from '../../src-shared/ipc/ipc-constants'; +import { Logger } from '../../src-shared/log/logger'; +import { ProxyRequire } from '../../src-shared/require/proxy-require'; + +const ipcRenderer = ProxyRequire.electron.ipcRenderer; + +ipcRenderer.on(IpcConstants.RecordAtAppLaunch.Finished, () => { + Logger.debug(`[IPC Renderer Received] ${IpcConstants.RecordAtAppLaunch.Finished}`); + window.plmInternalRenderer.recordAtAppLaunch.handleRecordAtAppLaunchFinished(); +}); diff --git a/type-declaration/window.d.ts b/type-declaration/window.d.ts index 994af255..5d989274 100644 --- a/type-declaration/window.d.ts +++ b/type-declaration/window.d.ts @@ -7,6 +7,7 @@ interface Window { } interface IPlmInternalRenderer { + recordAtAppLaunch: IPlmInternalRendererRecordAtAppLaunch; aboutBox: AboutBoxShowable; settingsDialog: SettingsDialogShowable; welcomeDialog: WelcomeDialogShowable; @@ -14,6 +15,10 @@ interface IPlmInternalRenderer { photoSelection: IPlmInternalRendererPhotoSelection; } +interface IPlmInternalRendererRecordAtAppLaunch { + handleRecordAtAppLaunchFinished(): void; +} + interface AboutBoxShowable { showAboutBox(): void; }