Fix issue that caused the value of certain settings to be inverted (#6896)

When using the SettingsStore.watchSetting() method for settings which have an
invertedSettingName, the newValueAt argument passed to the callback function,
would erroneously contain the inverted value.

This was making it so that such settings appeared to be disabled when they
should in fact be enabled, or vice-versa. This was however only the case for
code which took in account the newValueAt argument. Code using the newValue
argument was not affected.

The settings which have an invertedSettingName, and were thus potentially
impacted are:

- MessageComposerInput.dontSuggestEmoji
- hideRedactions
- hideJoinLeaves
- hideAvatarChanges
- hideDisplaynameChanges
- hideReadReceipts
- Pill.shouldHidePillAvatar
- TextualBody.disableBigEmoji
- dontSendTypingNotifications
- TagPanel.disableTagPanel
- webRtcForceTURN

Signed-off-by: Paulo Pinto <paulo.pinto@automattic.com>
pull/21833/head
Paulo Pinto 2021-10-07 15:42:23 +01:00 committed by GitHub
parent 1b5aef4447
commit 1b334e47aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -162,9 +162,10 @@ export default class SettingsStore {
const watcherId = `${new Date().getTime()}_${SettingsStore.watcherCount++}_${settingName}_${roomId}`;
const localizedCallback = (changedInRoomId, atLevel, newValAtLevel) => {
const localizedCallback = (changedInRoomId: string | null, atLevel: SettingLevel, newValAtLevel: any) => {
const newValue = SettingsStore.getValue(originalSettingName);
callbackFn(originalSettingName, changedInRoomId, atLevel, newValAtLevel, newValue);
const newValueAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName) ?? newValAtLevel;
callbackFn(originalSettingName, changedInRoomId, atLevel, newValueAtLevel, newValue);
};
SettingsStore.watchers.set(watcherId, localizedCallback);