From 3239172af9fb68226e1e11392b16f833b726ad72 Mon Sep 17 00:00:00 2001 From: Bennett Date: Fri, 17 Apr 2020 14:32:53 +0200 Subject: Merge Franz 5.5.0 beta.1 and 2 (#549) * Automatic i18n update (i18n.meetfranz.com) * Fix zoom not working * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Add environment variable FRANZ_APPDATA_DIR * Add environment variable for config FRANZ_APPDATA_DIR * fix stuff that shouldn't need fixing in the first place * notarize app * bump version to 5.4.1 * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * update to electron 7.1.7 * bump version to 5.5.0 * Automatic i18n update (i18n.meetfranz.com) * Bump electron to 7.1.10 * plan changes * filter plan variants * add missing string * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Replace/remove deprecated electron function calls Electron replaced several function calls with object properties. Franz still uses some of these deprecated functions, so this commit will replace these with their new property counterpart. This commit is only transferring the changes made in getferdi/ferdi#371 and getferdi/ferdi#384 into the upstream repository. * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Update to electron 8.0.1 * feat(Service): Add service hibernation to save system resources * Fix linting issues * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Bump version to electron 8.1.1 * update strings * update electron-notarize * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Automatic i18n update (i18n.meetfranz.com) * Add audio & video permission request for cataline * Automatic i18n update (i18n.meetfranz.com) * bump version to beta 1 * Automatic i18n update (i18n.meetfranz.com) * enable external links * Fix main content href * Automatic i18n update (i18n.meetfranz.com) * fix(Service): Fix issue with user agent override in service workers * Automatic i18n update (i18n.meetfranz.com) * fix macOS string replacement * Automatic i18n update (i18n.meetfranz.com) * fix(Experimental): Fix Google signin * fix(Service): Add integrity checks to prevent services recipes getting lost * Remove service reload on app-resume * update strings * bump version to beta 2 * Automatic i18n update (i18n.meetfranz.com) * bump electron-builder and electron-updater deps * test video permissions * fix `extendInfo` keys * fix typo * fix permission request * update camera/microphone entitlements * Automatic i18n update (i18n.meetfranz.com) * Test screen capture permissions * unpack `mac-screen-capture-permissions` * don't require localstorage temp key for permissions request * move macOS permission request to main process * Fix checking for permissions * fix(macOS): Ask the user to move Franz to the `/Applications` Folder * only try to recover recipe when user is online * update service request link * Update changelog * Reset `service.lostRecipeReloadAttempt` once service is alive again * Update translations * Fix crash on macOS * Fix merge errors * Fix lint * Disable ConnectionLostBanner * #551 Add information about Ferdi to the user agent * Fix requested changes * Remove tsbuildinfo files * Add .tsbuildinfo files to gitignore * Fix "Cannot destructure property 'app' of '_electron.remote' as it is undefined" Co-authored-by: FranzBot Co-authored-by: Makazzz Co-authored-by: Stefan Malzner --- src/stores/AppStore.js | 15 ++++++---- src/stores/ServicesStore.js | 67 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 8 deletions(-) (limited to 'src/stores') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index e2e3760a8..da6055e5f 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -218,13 +218,16 @@ export default class AppStore extends Store { // macOS catalina notifications hack // notifications got stuck after upgrade but forcing a notification // via `new Notification` triggered the permission request - if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { - // eslint-disable-next-line no-new - new window.Notification('Welcome to Franz 5', { - body: 'Have a wonderful day & happy messaging.', - }); + if (isMac) { + if (!localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { + debug('Triggering macOS Catalina notification permission trigger'); + // eslint-disable-next-line no-new + new window.Notification('Welcome to Franz 5', { + body: 'Have a wonderful day & happy messaging.', + }); - localStorage.setItem(CATALINA_NOTIFICATION_HACK_KEY, true); + localStorage.setItem(CATALINA_NOTIFICATION_HACK_KEY, true); + } } } diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 19e6f8299..80c7d7e81 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -5,7 +5,7 @@ import { computed, observable, } from 'mobx'; -import { remove } from 'lodash'; +import { debounce, remove } from 'lodash'; import ms from 'ms'; import fs from 'fs-extra'; import path from 'path'; @@ -127,6 +127,60 @@ export default class ServicesStore extends Store { ); } + initialize() { + super.initialize(); + + // Check services to become hibernated + this.serviceMaintenanceTick(); + } + + teardown() { + super.teardown(); + + // Stop checking services for hibernation + this.serviceMaintenanceTick.cancel(); + } + + /** + * Сheck for services to become hibernated. + */ + serviceMaintenanceTick = debounce(() => { + this._serviceMaintenance(); + this.serviceMaintenanceTick(); + debug('Service maintenance tick'); + }, ms('10s')); + + /** + * Run various maintenance tasks on services + */ + _serviceMaintenance() { + this.all.forEach((service) => { + // Defines which services should be hibernated. + if (!service.isActive && (Date.now() - service.lastUsed > ms('5m'))) { + // If service is stale for 5 min, hibernate it. + this._hibernate({ serviceId: service.id }); + } + + if (service.lastPoll && (service.lastPoll) - service.lastPollAnswer > ms('30s')) { + // If service did not reply for more than 30s try to reload. + if (!service.isActive) { + if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) { + service.webview.reload(); + service.lostRecipeReloadAttempt += 1; + + service.lostRecipeConnection = false; + } + } else { + service.lostRecipeConnection = true; + } + } else { + service.lostRecipeConnection = false; + service.lostRecipeReloadAttempt = 0; + } + }); + } + + // Computed props @computed get all() { if (this.stores.user.isLoggedIn) { const services = this.allServicesRequest.execute().result; @@ -379,6 +433,7 @@ export default class ServicesStore extends Store { this.all[index].isActive = false; }); service.isActive = true; + service.lastUsed = Date.now(); // Update list of last used services this.lastUsedServices = this.lastUsedServices.filter(id => id !== serviceId); @@ -475,10 +530,16 @@ export default class ServicesStore extends Store { const service = this.one(serviceId); if (channel === 'hello') { + debug('Received hello event from', serviceId); + this._initRecipePolling(service.id); this._initializeServiceRecipeInWebview(serviceId); this._shareSettingsWithServiceProcess(); + } else if (channel === 'alive') { + service.lastPollAnswer = Date.now(); } else if (channel === 'messages') { + debug(`Received unread message info from '${serviceId}'`, args[0]); + this.actions.service.setUnreadMessageCount({ serviceId, count: { @@ -600,6 +661,7 @@ export default class ServicesStore extends Store { if (!service.isEnabled) return; service.resetMessageCount(); + service.lostRecipeConnection = false; // service.webview.loadURL(service.url); service.webview.reload(); @@ -777,7 +839,7 @@ export default class ServicesStore extends Store { const isMuted = isAppMuted || service.isMuted; if (isAttached) { - service.webview.setAudioMuted(isMuted); + service.webview.audioMuted = isMuted; } }); } @@ -863,6 +925,7 @@ export default class ServicesStore extends Store { service.webview.send('poll'); service.timer = setTimeout(loop, delay); + service.lastPoll = Date.now(); }; loop(); -- cgit v1.2.3-70-g09d2