From bde7c579de4369e410ca2d87a2b5852b6a25dcc6 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Fri, 1 Oct 2021 16:39:40 +0100 Subject: [PATCH 1/4] Fix issue that caused the value of certain settings to be inverted 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 --- src/settings/SettingsStore.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index af858d23794..4f527a718bf 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -164,6 +164,7 @@ export default class SettingsStore { const localizedCallback = (changedInRoomId, atLevel, newValAtLevel) => { const newValue = SettingsStore.getValue(originalSettingName); + newValAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName); callbackFn(originalSettingName, changedInRoomId, atLevel, newValAtLevel, newValue); }; From 7181c7309220d3a02c9d5d367ab1e96a68296350 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Thu, 7 Oct 2021 15:17:02 +0100 Subject: [PATCH 2/4] Don't overwrite variable Signed-off-by: Paulo Pinto --- src/settings/SettingsStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index 4f527a718bf..9a15850156a 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -164,8 +164,8 @@ export default class SettingsStore { const localizedCallback = (changedInRoomId, atLevel, newValAtLevel) => { const newValue = SettingsStore.getValue(originalSettingName); - newValAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName); - callbackFn(originalSettingName, changedInRoomId, atLevel, newValAtLevel, newValue); + const newValueAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName); + callbackFn(originalSettingName, changedInRoomId, atLevel, newValueAtLevel, newValue); }; SettingsStore.watchers.set(watcherId, localizedCallback); From 1256570cc7c19b71f22e306b8d5d8da73542cfe2 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Thu, 7 Oct 2021 15:17:31 +0100 Subject: [PATCH 3/4] Fallback to original value Signed-off-by: Paulo Pinto --- src/settings/SettingsStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index 9a15850156a..6114c24627c 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -164,7 +164,7 @@ export default class SettingsStore { const localizedCallback = (changedInRoomId, atLevel, newValAtLevel) => { const newValue = SettingsStore.getValue(originalSettingName); - const newValueAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName); + const newValueAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName) ?? newValAtLevel; callbackFn(originalSettingName, changedInRoomId, atLevel, newValueAtLevel, newValue); }; From 32ad47bed8daa3d83ff634ee6bbd46b3abb07c05 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Thu, 7 Oct 2021 15:22:12 +0100 Subject: [PATCH 4/4] Define types for callback arguments Signed-off-by: Paulo Pinto --- src/settings/SettingsStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index 6114c24627c..d2f55689888 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -162,7 +162,7 @@ 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); const newValueAtLevel = SettingsStore.getValueAt(atLevel, originalSettingName) ?? newValAtLevel; callbackFn(originalSettingName, changedInRoomId, atLevel, newValueAtLevel, newValue);