diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 9acde2b80c..2926f4c87c 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1216,5 +1216,8 @@
"Import": "Import",
"Failed to set direct chat tag": "Failed to set direct chat tag",
"Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room",
- "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room"
+ "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room",
+ "Increase performance by only loading room members on first view": "Increase performance by only loading room members on first view",
+ "Lazy loading members not supported": "Lazy load members not supported",
+ "Lazy loading is not supported by your current homeserver.": "Lazy loading is not supported by your current homeserver."
}
diff --git a/src/settings/Settings.js b/src/settings/Settings.js
index d76c1fd8e8..0594c63eb9 100644
--- a/src/settings/Settings.js
+++ b/src/settings/Settings.js
@@ -21,7 +21,7 @@ import {
NotificationBodyEnabledController,
NotificationsEnabledController,
} from "./controllers/NotificationControllers";
-
+import LazyLoadingController from "./controllers/LazyLoadingController";
// 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'];
@@ -85,8 +85,10 @@ export const SETTINGS = {
},
"feature_lazyloading": {
isFeature: true,
- displayName: _td("Increase performance by loading room members on first view"),
+ displayName: _td("Increase performance by only loading room members on first view"),
supportedLevels: LEVELS_FEATURE,
+ controller: new LazyLoadingController(),
+ default: false,
},
"MessageComposerInput.dontSuggestEmoji": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
diff --git a/src/settings/SettingsStore.js b/src/settings/SettingsStore.js
index a1b88fb0c2..cb6d83e884 100644
--- a/src/settings/SettingsStore.js
+++ b/src/settings/SettingsStore.js
@@ -248,7 +248,7 @@ export default class SettingsStore {
if (actualValue !== undefined && actualValue !== null) return actualValue;
return calculatedValue;
}
-
+ /* eslint-disable valid-jsdoc */ //https://github.com/eslint/eslint/issues/7307
/**
* Sets the value for a setting. The room ID is optional if the setting is not being
* set for a particular room, otherwise it should be supplied. The value may be null
@@ -260,7 +260,8 @@ export default class SettingsStore {
* @param {*} value The new value of the setting, may be null.
* @return {Promise} Resolves when the setting has been changed.
*/
- static setValue(settingName, roomId, level, value) {
+ /* eslint-enable valid-jsdoc */
+ static async setValue(settingName, roomId, level, value) {
// Verify that the setting is actually a setting
if (!SETTINGS[settingName]) {
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
@@ -275,11 +276,12 @@ export default class SettingsStore {
throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId);
}
- return handler.setValue(settingName, roomId, value).then(() => {
- const controller = SETTINGS[settingName].controller;
- if (!controller) return;
+ await handler.setValue(settingName, roomId, value);
+
+ const controller = SETTINGS[settingName].controller;
+ if (controller) {
controller.onChange(level, roomId, value);
- });
+ }
}
/**
diff --git a/src/settings/controllers/LazyLoadingController.js b/src/settings/controllers/LazyLoadingController.js
new file mode 100644
index 0000000000..90f095c9ca
--- /dev/null
+++ b/src/settings/controllers/LazyLoadingController.js
@@ -0,0 +1,29 @@
+/*
+Copyright 2018 New Vector
+
+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 MatrixClientPeg from "../../MatrixClientPeg";
+import PlatformPeg from "../../PlatformPeg";
+
+export default class LazyLoadingController extends SettingController {
+ async onChange(level, roomId, newValue) {
+ if (!PlatformPeg.get()) return;
+
+ MatrixClientPeg.get().stopClient();
+ await MatrixClientPeg.get().store.deleteAllData();
+ PlatformPeg.get().reload();
+ }
+}