From 0d47222132bed37fc3928dec4be27e56f8d12b9d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 30 May 2019 19:57:17 -0600 Subject: [PATCH] Add LB setting to new user settings Put under labs out of concern for https://github.com/vector-im/riot-meta/issues/66 --- .../settings/tabs/user/LabsUserSettingsTab.js | 1 + src/i18n/strings/en_EN.json | 1 + src/settings/Settings.js | 4 +++- .../controllers/LowBandwidthController.js | 24 +++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/settings/controllers/LowBandwidthController.js diff --git a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js index d272d74d29..23b5e516cd 100644 --- a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js @@ -53,6 +53,7 @@ export default class LabsUserSettingsTab extends React.Component { {flags} + ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 343e75bcf3..e34ed093e7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -339,6 +339,7 @@ "Show developer tools": "Show developer tools", "Order rooms in the room list by most important first instead of most recent": "Order rooms in the room list by most important first instead of most recent", "Show hidden events in timeline": "Show hidden events in timeline", + "Low bandwidth mode": "Low bandwidth mode", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading report": "Uploading report", diff --git a/src/settings/Settings.js b/src/settings/Settings.js index c8778b9d5c..2c911dda80 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -23,6 +23,7 @@ import { } from "./controllers/NotificationControllers"; import CustomStatusController from "./controllers/CustomStatusController"; import ThemeController from './controllers/ThemeController'; +import LowBandwidthController from "./controllers/LowBandwidthController"; // These are just a bunch of helper arrays to avoid copy/pasting a bunch of times const LEVELS_ROOM_SETTINGS = ['device', 'room-device', 'room-account', 'account', 'config']; @@ -375,7 +376,8 @@ export const SETTINGS = { }, "lowBandwidth": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, - displayName: _td('Low Bandwidth Mode'), + displayName: _td('Low bandwidth mode'), default: false, + controller: new LowBandwidthController(), }, }; diff --git a/src/settings/controllers/LowBandwidthController.js b/src/settings/controllers/LowBandwidthController.js new file mode 100644 index 0000000000..c7796a425a --- /dev/null +++ b/src/settings/controllers/LowBandwidthController.js @@ -0,0 +1,24 @@ +/* +Copyright 2019 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import SettingController from "./SettingController"; +import PlatformPeg from "../../PlatformPeg"; + +export default class LowBandwidthController extends SettingController { + onChange(level, roomId, newValue) { + PlatformPeg.get().reload(); + } +}