diff --git a/quasar.conf.js b/quasar.conf.js index 34df237c..ce491369 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -222,7 +222,7 @@ module.exports = configure(function (ctx) { builder: { // https://www.electron.build/configuration/configuration appId: 'dev.paperlib.app', - productName: 'paperlib', + productName: 'Paperlib', publish: [ { provider: 'generic', diff --git a/quasar.conf.mac.js b/quasar.conf.mac.js index 34df237c..ce491369 100644 --- a/quasar.conf.mac.js +++ b/quasar.conf.mac.js @@ -222,7 +222,7 @@ module.exports = configure(function (ctx) { builder: { // https://www.electron.build/configuration/configuration appId: 'dev.paperlib.app', - productName: 'paperlib', + productName: 'Paperlib', publish: [ { provider: 'generic', diff --git a/quasar.conf.win.js b/quasar.conf.win.js index e87f51fb..adc18a1c 100644 --- a/quasar.conf.win.js +++ b/quasar.conf.win.js @@ -222,7 +222,7 @@ module.exports = configure(function (ctx) { builder: { // https://www.electron.build/configuration/configuration appId: 'dev.paperlib.app', - productName: 'paperlib', + productName: 'Paperlib', publish: [ { provider: 'generic', diff --git a/src-electron/electron-main.js b/src-electron/electron-main.js index eb44ae44..d5e292d1 100644 --- a/src-electron/electron-main.js +++ b/src-electron/electron-main.js @@ -67,6 +67,14 @@ function createWindow() { mainWindow = null; }); + mainWindow.on('blur', () => { + mainWindow.webContents.send('window-lost-focus'); + }); + + mainWindow.on('focus', () => { + mainWindow.webContents.send('window-gained-focus'); + }); + setMainMenu(); } diff --git a/src/css/preference-view.scss b/src/css/preference-view.scss index c8a55403..8dff0928 100644 --- a/src/css/preference-view.scss +++ b/src/css/preference-view.scss @@ -1,6 +1,6 @@ .preference-view { width: 800px; - height: 420px; + min-height: 450px; background-color: var(--q-bg-primary) !important; color: var(--q-text) !important; } diff --git a/src/interactors/entity-interactor.ts b/src/interactors/entity-interactor.ts index 0652f2e0..3c6cd433 100644 --- a/src/interactors/entity-interactor.ts +++ b/src/interactors/entity-interactor.ts @@ -358,6 +358,27 @@ export class EntityInteractor { this.sharedState.set('viewState.realmReinited', new Date().getTime()); } + pauseSync() { + this.scheduler.removeById('pauseSync'); + const task = new Task('pauseSync', () => { + void this.dbRepository.pauseSync(); + this.scheduler.removeById('pauseSync'); + }); + + const job = new SimpleIntervalJob( + { seconds: 36, runImmediately: false }, + task, + 'pauseSync' + ); + + this.scheduler.addSimpleIntervalJob(job); + } + + resumeSync() { + this.scheduler.removeById('pauseSync'); + void this.dbRepository.resumeSync(); + } + // ============================================================ initFileRepository() { if (this.preference.get('syncFileStorage') === 'webdav') { diff --git a/src/pages/Index.vue b/src/pages/Index.vue index ce99add2..7acb89c7 100644 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -177,6 +177,14 @@ export default defineComponent({ void window.entityInteractor.addFromPlugin([message as string]); }); + window.systemInteractor.registerSignal('window-lost-focus', (_event, _message) => { + void window.entityInteractor.pauseSync(); + }); + + window.systemInteractor.registerSignal('window-gained-focus', (_event, _message) => { + void window.entityInteractor.resumeSync(); + }); + window.systemInteractor.registerState('viewState.realmReinited', (_event, _message) => { void (async () => { await reloadEntities(); diff --git a/src/pages/preference_view/components/CloudTab.vue b/src/pages/preference_view/components/CloudTab.vue index bc64f4f7..f9a431de 100644 --- a/src/pages/preference_view/components/CloudTab.vue +++ b/src/pages/preference_view/components/CloudTab.vue @@ -1,5 +1,32 @@