From 96e9a68abdaa1438d94cd442d3b1dd9e986a4cd6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 20 Feb 2020 00:08:47 +1100 Subject: [PATCH] add zoomfactor to main --- js/background.js | 9 +++++++++ main.js | 3 +++ preload.js | 5 +++++ .../session/settings/SessionSettings.tsx | 17 ++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/js/background.js b/js/background.js index 123dca978..983afc0c0 100644 --- a/js/background.js +++ b/js/background.js @@ -324,6 +324,15 @@ storage.put('message-ttl', ttl); }, + + getZoomFactor: () => storage.get('zoom-factor-setting', 48), + setZoomFactor: value => { + // Make sure the ttl is between a given range and is valid + const intValue = parseInt(value, 10); + const factor = Number.isNaN(intValue) ? 24 : intValue; + storage.put('zoom-factor-setting', factor); + }, + getReadReceiptSetting: () => storage.get('read-receipt-setting'), setReadReceiptSetting: value => storage.put('read-receipt-setting', value), diff --git a/main.js b/main.js index 2eb625db8..86866b1bd 100644 --- a/main.js +++ b/main.js @@ -577,6 +577,7 @@ let settingsWindow; async function showSettingsWindow() { if (settingsWindow) { settingsWindow.show(); + console.log(window.getSettingValue('zoom-factor-setting'), 'from settingsWindow') return; } if (!mainWindow) { @@ -836,6 +837,7 @@ async function showMainWindow(sqlKey, passwordAttempt = false) { createWindow(); + if (usingTrayIcon) { tray = createTrayIcon(getMainWindow, locale.messages); } @@ -1025,6 +1027,7 @@ ipc.on('password-window-login', async (event, passPhrase) => { const passwordAttempt = true; await showMainWindow(passPhrase, passwordAttempt); sendResponse(); + if (passwordWindow) { passwordWindow.close(); passwordWindow = null; diff --git a/preload.js b/preload.js index 8fb3936d1..78ec9a2a6 100644 --- a/preload.js +++ b/preload.js @@ -228,6 +228,11 @@ window.getMessageTTL = () => window.storage.get('message-ttl', 24); installGetter('message-ttl', 'getMessageTTL'); installSetter('message-ttl', 'setMessageTTL'); +// Get the zoom Factor setting +window.getZoomFactor = () => window.storage.get('zoom-factor-setting',50) +installGetter('zoom-factor-setting', 'getZoomFactor'); +installSetter('zoom-factor-setting', 'setZoomFactor'); + installGetter('read-receipt-setting', 'getReadReceiptSetting'); installSetter('read-receipt-setting', 'setReadReceiptSetting'); diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 0d6d6c3b2..4524fd167 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -490,6 +490,21 @@ export class SettingsView extends React.Component { }, confirmationDialogParams: undefined, }, + { + id: 'zoom-factor-setting', + title: window.i18n('zoomFactorSettingTitle'), + description: window.i18n('zoomFactorSettingTitleDescription'), + hidden: false, + type: SessionSettingType.Slider, + category: SessionSettingCategory.Appearance, + setFn: undefined, + comparisonValue: undefined, + onClick: undefined, + content: { + defaultValue: 24, + }, + confirmationDialogParams: undefined, + }, { id: 'read-receipt-setting', title: window.i18n('readReceiptSettingTitle'), @@ -575,7 +590,7 @@ export class SettingsView extends React.Component { onSuccess: this.onPasswordUpdated, }), confirmationDialogParams: undefined, - }, + } ]; }