Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix issue that caused the value of certain settings to be inverted (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
psrpinto authored Oct 7, 2021
1 parent 1b5aef4 commit 1b334e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/settings/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1b334e4

Please sign in to comment.