From 54f7533673d7ada520ee25c2a8ecd6feab28252a Mon Sep 17 00:00:00 2001 From: Vijay A Date: Mon, 6 Sep 2021 20:32:08 +0530 Subject: Revert "refactor: trying to fix zoom in/out being sticky for the last active service when started up" This reverts commit 947a776e1ed902a218af0f634bfa9d320678ce93. --- src/lib/Menu.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/lib/Menu.js') diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 01bdb0bec..8a5af56fb 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -28,8 +28,6 @@ import { workspaceStore } from '../features/workspaces/index'; import apiBase, { termsBase } from '../api/apiBase'; import { openExternalUrl } from '../helpers/url-helpers'; -const debug = require('debug')('Ferdi:Menu'); - const menuItems = defineMessages({ edit: { id: 'menu.edit', @@ -323,8 +321,7 @@ const menuItems = defineMessages({ }); function getActiveService() { - // TODO: How is this different from `this.actions.service.active` which is in the ServicesStore class? - return this.stores.services.active; + return window.ferdi.stores.services.active; } const _titleBarTemplateFactory = (intl, locked) => [ @@ -407,8 +404,6 @@ const _titleBarTemplateFactory = (intl, locked) => [ channel: 'find-in-page', args: {}, }); - } else { - debug('No service is active'); } }, }, @@ -436,21 +431,29 @@ const _titleBarTemplateFactory = (intl, locked) => [ label: intl.formatMessage(menuItems.resetZoom), accelerator: `${cmdOrCtrlShortcutKey()}+0`, click() { - this.actions.service.zoomResetForActiveService(); + getActiveService().webview.setZoomLevel(0); }, }, { label: intl.formatMessage(menuItems.zoomIn), accelerator: `${cmdOrCtrlShortcutKey()}+plus`, click() { - this.actions.service.zoomInForActiveService(); + const activeService = getActiveService().webview; + const level = activeService.getZoomLevel(); + + // level 9 =~ +300% and setZoomLevel wouldnt zoom in further + if (level < 9) activeService.setZoomLevel(level + 1); }, }, { label: intl.formatMessage(menuItems.zoomOut), accelerator: `${cmdOrCtrlShortcutKey()}+-`, click() { - this.actions.service.zoomOutForActiveService(); + const activeService = getActiveService().webview; + const level = activeService.getZoomLevel(); + + // level -9 =~ -50% and setZoomLevel wouldnt zoom out further + if (level > -9) activeService.setZoomLevel(level - 1); }, }, { -- cgit v1.2.3-70-g09d2