mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
Add reloadApp helper and fix macOS -120 error on backup restoration
Co-authored-by: johannesjo <1456265+johannesjo@users.noreply.github.com>
This commit is contained in:
parent
6dc0814973
commit
ec5d9d0696
3 changed files with 22 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ import { T } from '../../../t.const';
|
|||
import { CommonModule } from '@angular/common';
|
||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||
import { SyncLog } from '../../../core/log';
|
||||
import { reloadApp } from '../../../util/reload-app';
|
||||
|
||||
@Component({
|
||||
selector: 'sync-safety-backups',
|
||||
|
|
@ -97,7 +98,7 @@ export class SyncSafetyBackupsComponent implements OnInit, OnDestroy {
|
|||
msg: T.F.SYNC.SAFETY_BACKUP.RESTORED_SUCCESS,
|
||||
});
|
||||
// Reload the page after restoration
|
||||
setTimeout(() => window.location.reload(), 1000);
|
||||
setTimeout(() => reloadApp(), 1000);
|
||||
} catch (error) {
|
||||
SyncLog.err('Failed to restore backup:', error);
|
||||
this._snackService.open({
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import { fromPfapiEvent, pfapiEventAndInitialAfter } from './pfapi-helper';
|
|||
import { DataInitStateService } from '../core/data-init/data-init-state.service';
|
||||
import { GlobalProgressBarService } from '../core-ui/global-progress-bar/global-progress-bar.service';
|
||||
import { PFLog } from '../core/log';
|
||||
import { reloadApp } from '../util/reload-app';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -160,7 +161,7 @@ export class PfapiService {
|
|||
|
||||
this._imexViewService.setDataImportInProgress(false);
|
||||
if (!isSkipReload) {
|
||||
window.location.reload();
|
||||
reloadApp();
|
||||
}
|
||||
} catch (e) {
|
||||
this._imexViewService.setDataImportInProgress(false);
|
||||
|
|
|
|||
18
src/app/util/reload-app.ts
Normal file
18
src/app/util/reload-app.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { IS_ELECTRON } from '../app.constants';
|
||||
|
||||
/**
|
||||
* Reloads the application properly in both Electron and browser contexts.
|
||||
* In Electron (especially on macOS), using window.location.reload() can cause
|
||||
* errors like "The application can't be opened. -120". This function uses the
|
||||
* proper Electron IPC event when running in Electron, and falls back to
|
||||
* window.location.reload() in browser contexts.
|
||||
*/
|
||||
export function reloadApp(): void {
|
||||
if (IS_ELECTRON && window.ea && typeof window.ea.reloadMainWin === 'function') {
|
||||
// Use Electron's proper reload method via IPC
|
||||
window.ea.reloadMainWin();
|
||||
} else {
|
||||
// Fallback for browser/PWA context
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue