Merge branch 'develop' into travis/remove-presence
This commit is contained in:
commit
fe2cbc584d
246 changed files with 16884 additions and 4954 deletions
|
@ -76,6 +76,12 @@ export const SETTINGS = {
|
|||
// // level is always appended to the end.
|
||||
// supportedLevelsAreOrdered: false,
|
||||
// },
|
||||
"feature_rich_quoting": {
|
||||
isFeature: true,
|
||||
displayName: _td("Message Replies"),
|
||||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
},
|
||||
"feature_pinning": {
|
||||
isFeature: true,
|
||||
displayName: _td("Message Pinning"),
|
||||
|
@ -88,6 +94,12 @@ export const SETTINGS = {
|
|||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
},
|
||||
"feature_sticker_messages": {
|
||||
isFeature: true,
|
||||
displayName: _td("Sticker Messages"),
|
||||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
},
|
||||
"MessageComposerInput.dontSuggestEmoji": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Disable Emoji suggestions while typing'),
|
||||
|
@ -176,6 +188,11 @@ export const SETTINGS = {
|
|||
displayName: _td('Mirror local video feed'),
|
||||
default: false,
|
||||
},
|
||||
"TagPanel.disableTagPanel": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Disable Community Filter Panel'),
|
||||
default: false,
|
||||
},
|
||||
"theme": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
default: "light",
|
||||
|
|
|
@ -222,9 +222,9 @@ export default class SettingsStore {
|
|||
|
||||
if (explicit) {
|
||||
const handler = handlers[level];
|
||||
if (!handler) return SettingsStore._tryControllerOverride(settingName, level, roomId, null);
|
||||
if (!handler) return SettingsStore._tryControllerOverride(settingName, level, roomId, null, null);
|
||||
const value = handler.getValue(settingName, roomId);
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, value);
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, value, level);
|
||||
}
|
||||
|
||||
for (let i = minIndex; i < levelOrder.length; i++) {
|
||||
|
@ -234,17 +234,17 @@ export default class SettingsStore {
|
|||
|
||||
const value = handler.getValue(settingName, roomId);
|
||||
if (value === null || value === undefined) continue;
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, value);
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, value, levelOrder[i]);
|
||||
}
|
||||
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, null);
|
||||
return SettingsStore._tryControllerOverride(settingName, level, roomId, null, null);
|
||||
}
|
||||
|
||||
static _tryControllerOverride(settingName, level, roomId, calculatedValue) {
|
||||
static _tryControllerOverride(settingName, level, roomId, calculatedValue, calculatedAtLevel) {
|
||||
const controller = SETTINGS[settingName].controller;
|
||||
if (!controller) return calculatedValue;
|
||||
|
||||
const actualValue = controller.getValueOverride(level, roomId, calculatedValue);
|
||||
const actualValue = controller.getValueOverride(level, roomId, calculatedValue, calculatedAtLevel);
|
||||
if (actualValue !== undefined && actualValue !== null) return actualValue;
|
||||
return calculatedValue;
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ function isMasterRuleEnabled() {
|
|||
}
|
||||
|
||||
export class NotificationsEnabledController extends SettingController {
|
||||
getValueOverride(level, roomId, calculatedValue) {
|
||||
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
|
||||
const Notifier = require('../../Notifier'); // avoids cyclical references
|
||||
if (!Notifier.isPossible()) return false;
|
||||
|
||||
if (calculatedValue === null) {
|
||||
if (calculatedValue === null || calculatedAtLevel === "default") {
|
||||
return isMasterRuleEnabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,11 @@ export default class SettingController {
|
|||
* @param {String} roomId The room ID, may be null.
|
||||
* @param {*} calculatedValue The value that the handlers think the setting should be,
|
||||
* may be null.
|
||||
* @param {string} calculatedAtLevel The level for which the calculated value was
|
||||
* calculated at. May be null.
|
||||
* @return {*} The value that should be used, or null if no override is applicable.
|
||||
*/
|
||||
getValueOverride(level, roomId, calculatedValue) {
|
||||
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
|
||||
return null; // no override
|
||||
}
|
||||
|
||||
|
|
|
@ -25,19 +25,20 @@ export default class AccountSettingHandler extends SettingsHandler {
|
|||
getValue(settingName, roomId) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings("org.matrix.preview_urls");
|
||||
const content = this._getSettings("org.matrix.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof(content['disable']) !== "boolean") return null;
|
||||
return !content['disable'];
|
||||
}
|
||||
|
||||
let preferredValue = this._getSettings()[settingName];
|
||||
const settings = this._getSettings() || {};
|
||||
let preferredValue = settings[settingName];
|
||||
|
||||
if (preferredValue === null || preferredValue === undefined) {
|
||||
// Honour the old setting on read only
|
||||
if (settingName === "hideAvatarChanges" || settingName === "hideDisplaynameChanges") {
|
||||
preferredValue = this._getSettings()["hideAvatarDisplaynameChanges"];
|
||||
preferredValue = settings["hideAvatarDisplaynameChanges"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,12 +48,12 @@ export default class AccountSettingHandler extends SettingsHandler {
|
|||
setValue(settingName, roomId, newValue) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings("org.matrix.preview_urls");
|
||||
const content = this._getSettings("org.matrix.preview_urls") || {};
|
||||
content['disable'] = !newValue;
|
||||
return MatrixClientPeg.get().setAccountData("org.matrix.preview_urls", content);
|
||||
}
|
||||
|
||||
const content = this._getSettings();
|
||||
const content = this._getSettings() || {};
|
||||
content[settingName] = newValue;
|
||||
return MatrixClientPeg.get().setAccountData("im.vector.web.settings", content);
|
||||
}
|
||||
|
@ -68,9 +69,10 @@ export default class AccountSettingHandler extends SettingsHandler {
|
|||
|
||||
_getSettings(eventType = "im.vector.web.settings") {
|
||||
const cli = MatrixClientPeg.get();
|
||||
if (!cli) return {};
|
||||
if (!cli) return null;
|
||||
|
||||
const event = cli.getAccountData(eventType);
|
||||
if (!event || !event.getContent()) return {};
|
||||
if (!event || !event.getContent()) return null;
|
||||
return event.getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return null; // wrong type or otherwise not set
|
||||
}
|
||||
|
||||
return this._getSettings()[settingName];
|
||||
const settings = this._getSettings() || {};
|
||||
return settings[settingName];
|
||||
}
|
||||
|
||||
setValue(settingName, roomId, newValue) {
|
||||
|
@ -74,7 +75,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const settings = this._getSettings();
|
||||
const settings = this._getSettings() || {};
|
||||
settings[settingName] = newValue;
|
||||
localStorage.setItem("mx_local_settings", JSON.stringify(settings));
|
||||
|
||||
|
@ -91,7 +92,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
|
||||
_getSettings() {
|
||||
const value = localStorage.getItem("mx_local_settings");
|
||||
if (!value) return {};
|
||||
if (!value) return null;
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
_readFeature(featureName) {
|
||||
if (MatrixClientPeg.get() && MatrixClientPeg.get().isGuest()) {
|
||||
// Guests should not have any labs features enabled.
|
||||
return {enabled: false};
|
||||
return false;
|
||||
}
|
||||
|
||||
const value = localStorage.getItem("mx_labs_feature_" + featureName);
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
|
|||
getValue(settingName, roomId) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof(content['disable']) !== "boolean") return null;
|
||||
|
@ -35,16 +35,18 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
|
|||
if (settingName === "roomColor") {
|
||||
// The event content should already be in an appropriate format, we just need
|
||||
// to get the right value.
|
||||
// don't fallback to {} because thats truthy and would imply there is an event specifying tint
|
||||
return this._getSettings(roomId, "org.matrix.room.color_scheme");
|
||||
}
|
||||
|
||||
return this._getSettings(roomId)[settingName];
|
||||
const settings = this._getSettings(roomId) || {};
|
||||
return settings[settingName];
|
||||
}
|
||||
|
||||
setValue(settingName, roomId, newValue) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
content['disable'] = !newValue;
|
||||
return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.preview_urls", content);
|
||||
}
|
||||
|
@ -55,7 +57,7 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
|
|||
return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.color_scheme", newValue);
|
||||
}
|
||||
|
||||
const content = this._getSettings(roomId);
|
||||
const content = this._getSettings(roomId) || {};
|
||||
content[settingName] = newValue;
|
||||
return MatrixClientPeg.get().setRoomAccountData(roomId, "im.vector.web.settings", content);
|
||||
}
|
||||
|
@ -74,10 +76,10 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
|
|||
|
||||
_getSettings(roomId, eventType = "im.vector.settings") {
|
||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||
if (!room) return {};
|
||||
if (!room) return null;
|
||||
|
||||
const event = room.getAccountData(eventType);
|
||||
if (!event || !event.getContent()) return {};
|
||||
if (!event || !event.getContent()) return null;
|
||||
return event.getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,25 +24,26 @@ export default class RoomSettingsHandler extends SettingsHandler {
|
|||
getValue(settingName, roomId) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
|
||||
// Check to make sure that we actually got a boolean
|
||||
if (typeof(content['disable']) !== "boolean") return null;
|
||||
return !content['disable'];
|
||||
}
|
||||
|
||||
return this._getSettings(roomId)[settingName];
|
||||
const settings = this._getSettings(roomId) || {};
|
||||
return settings[settingName];
|
||||
}
|
||||
|
||||
setValue(settingName, roomId, newValue) {
|
||||
// Special case URL previews
|
||||
if (settingName === "urlPreviewsEnabled") {
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
|
||||
const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {};
|
||||
content['disable'] = !newValue;
|
||||
return MatrixClientPeg.get().sendStateEvent(roomId, "org.matrix.room.preview_urls", content);
|
||||
}
|
||||
|
||||
const content = this._getSettings(roomId);
|
||||
const content = this._getSettings(roomId) || {};
|
||||
content[settingName] = newValue;
|
||||
return MatrixClientPeg.get().sendStateEvent(roomId, "im.vector.web.settings", content, "");
|
||||
}
|
||||
|
@ -65,9 +66,10 @@ export default class RoomSettingsHandler extends SettingsHandler {
|
|||
|
||||
_getSettings(roomId, eventType = "im.vector.web.settings") {
|
||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||
if (!room) return {};
|
||||
if (!room) return null;
|
||||
|
||||
const event = room.currentState.getStateEvents(eventType, "");
|
||||
if (!event || !event.getContent()) return {};
|
||||
if (!event || !event.getContent()) return null;
|
||||
return event.getContent();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue