Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run “open after launch“ in frontend after finishing “recording at app launch” in backend. #570

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src-main/record-at-app-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand All @@ -128,4 +134,6 @@ export const recordAtAppLaunch = () => {

recordSidebarMenuSortKey();
recordSideBarMenuSortDirection();

finishRecordAtAppLaunch();
};
4 changes: 4 additions & 0 deletions src-shared/ipc/ipc-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
13 changes: 10 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PlmInternalRenderer,
PlmInternalRendererAboutBox,
PlmInternalRendererPhotoSelection,
PlmInternalRendererRecordAtAppLaunch,
PlmInternalRendererSettingsDialog,
PlmInternalRendererWelcomeDialog
} from '../global-variables/global-variable-for-internal-use-in-renderer';
Expand Down Expand Up @@ -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();

Expand All @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
export class PlmInternalRenderer implements IPlmInternalRenderer {
public recordAtAppLaunch: PlmInternalRendererRecordAtAppLaunch;
public aboutBox: PlmInternalRendererAboutBox;
public settingsDialog: PlmInternalRendererSettingsDialog;
public welcomeDialog: PlmInternalRendererWelcomeDialog;
public map: PlmInternalRendererMap;
public photoSelection: IPlmInternalRendererPhotoSelection;
}

export class PlmInternalRendererRecordAtAppLaunch implements IPlmInternalRendererRecordAtAppLaunch {
public handleRecordAtAppLaunchFinished: () => void;
}

export class PlmInternalRendererAboutBox implements AboutBoxShowable {
public showAboutBox: () => void;
}
Expand Down
1 change: 1 addition & 0 deletions src/ipc-renderer-setup/ipc-renderer-all-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
10 changes: 10 additions & 0 deletions src/ipc-renderer-setup/ipc-renderer-record-at-app-launch-setup.ts
Original file line number Diff line number Diff line change
@@ -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();
});
5 changes: 5 additions & 0 deletions type-declaration/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ interface Window {
}

interface IPlmInternalRenderer {
recordAtAppLaunch: IPlmInternalRendererRecordAtAppLaunch;
aboutBox: AboutBoxShowable;
settingsDialog: SettingsDialogShowable;
welcomeDialog: WelcomeDialogShowable;
map: MapChangeable;
photoSelection: IPlmInternalRendererPhotoSelection;
}

interface IPlmInternalRendererRecordAtAppLaunch {
handleRecordAtAppLaunchFinished(): void;
}

interface AboutBoxShowable {
showAboutBox(): void;
}
Expand Down
Loading