Merge pull request #4032 from matrix-org/t3chguy/watcher_id

SettingsStore, use a counter instead of wall clock for watcher ids
This commit is contained in:
Michael Telatynski 2020-02-04 11:32:12 +00:00 committed by GitHub
commit 3a2cf87791
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -113,6 +113,9 @@ export default class SettingsStore {
static _watchers = {}; // { callbackRef => { callbackFn } }
static _monitors = {}; // { settingName => { roomId => callbackRef } }
// Counter used for generation of watcher IDs
static _watcherCount = 1;
/**
* Watches for changes in a particular setting. This is done without any local echo
* wrapping and fires whenever a change is detected in a setting's value, at any level.
@ -138,7 +141,7 @@ export default class SettingsStore {
settingName = setting.invertedSettingName;
}
const watcherId = `${new Date().getTime()}_${settingName}_${roomId}`;
const watcherId = `${new Date().getTime()}_${SettingsStore._watcherCount++}_${settingName}_${roomId}`;
const localizedCallback = (changedInRoomId, atLevel, newValAtLevel) => {
const newValue = SettingsStore.getValue(originalSettingName);