From 55e72dd5bf826fd8fb9cfb3f7b769ad682247b67 Mon Sep 17 00:00:00 2001 From: Jorik Schellekens Date: Wed, 20 May 2020 13:45:54 +0100 Subject: [PATCH] Remove min and max font setting --- src/FontWatcher.js | 9 +++++---- .../settings/tabs/user/AppearanceUserSettingsTab.js | 6 +++--- src/settings/Settings.js | 10 ---------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/FontWatcher.js b/src/FontWatcher.js index 561edc4662..1128ac1bd5 100644 --- a/src/FontWatcher.js +++ b/src/FontWatcher.js @@ -18,6 +18,10 @@ import dis from './dispatcher'; import SettingsStore, {SettingLevel} from './settings/SettingsStore'; export class FontWatcher { + + static minSize = 13; + static maxSize = 20; + constructor() { this._dispatcherRef = null; } @@ -38,10 +42,7 @@ export class FontWatcher { }; _setRootFontSize = (size) => { - const min = SettingsStore.getValue("fontSizeMin"); - const max = SettingsStore.getValue("fontSizeMax"); - - const fontSize = Math.max(Math.min(max, size), min); + const fontSize = Math.max(Math.min(this.maxSize, size), this.minSize); if (fontSize != size) { SettingsStore.setValue("fontSize", null, SettingLevel.Device, fontSize); diff --git a/src/components/views/settings/tabs/user/AppearanceUserSettingsTab.js b/src/components/views/settings/tabs/user/AppearanceUserSettingsTab.js index 63857ed9c2..308b7098d1 100644 --- a/src/components/views/settings/tabs/user/AppearanceUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/AppearanceUserSettingsTab.js @@ -25,7 +25,7 @@ import Field from "../../../elements/Field"; import Slider from "../../../elements/Slider"; import AccessibleButton from "../../../elements/AccessibleButton"; import dis from "../../../../../dispatcher"; -import _range from "lodash/range"; +import { FontWatcher } from "../../../../../FontWatcher"; export default class AppearanceUserSettingsTab extends React.Component { constructor() { @@ -109,8 +109,8 @@ export default class AppearanceUserSettingsTab extends React.Component { console.log({value}); const parsedSize = parseFloat(value); - const min = SettingsStore.getValue("fontSizeMin"); - const max = SettingsStore.getValue("fontSizeMax"); + const min = FontWatcher.minSize; + const max = FontWatcher.maxSize; if (isNaN(parsedSize)) { return {valid: false, feedback: _t("Size must be a number")}; diff --git a/src/settings/Settings.js b/src/settings/Settings.js index afe8d2cecc..5f093f6a70 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -171,16 +171,6 @@ export const SETTINGS = { default: 16, controller: new FontSizeController(), }, - "fontSizeMin": { - displayName: _td("Min font size"), - supportedLevels: LEVELS_ACCOUNT_SETTINGS, - default: 13, - }, - "fontSizeMax": { - displayName: _td("Max font size"), - supportedLevels: LEVELS_ACCOUNT_SETTINGS, - default: 20, - }, "useCustomFontSize": { displayName: _td("Custom font size"), supportedLevels: LEVELS_ACCOUNT_SETTINGS,