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

Use a global WatchManager for settings #2705

Merged
merged 2 commits into from
Feb 27, 2019

Conversation

turt2live
Copy link
Member

Fixes element-hq/element-web#8936

Note to the reviewer: It may be easier to review this commit-by-commit. I've included some attempts to make the diff more legible for the settings documentation.

Watchers are now managed by the SettingsStore itself through a global/default watch manager. As per the included documentation, the watch manager dispatches updates to callbacks which are redirected by the SettingsStore for consumer safety.

@turt2live turt2live requested a review from a team February 26, 2019 19:49
Fixes element-hq/element-web#8936

Watchers are now managed by the SettingsStore itself through a global/default watch manager. As per the included documentation, the watch manager dispatches updates to callbacks which are redirected by the SettingsStore for consumer safety.
@turt2live turt2live force-pushed the travis/fix-monitored-settings branch from 8fcfb01 to fbffd3e Compare February 26, 2019 19:53
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!! One suggestion for further potential simplification, but lgtm!

}
console.log(`Starting watcher for ${settingName}@${roomId || '<null room>'}`);
SettingsStore._watchers[watcherId] = localizedCallback;
defaultWatchManager.watchSetting(settingName, roomId, localizedCallback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could wonder now if the WatchManager is still needed. It only ever has one watcher for a setting, so it might further simplify by bringing it into SettingsStore and merging it with _watchers. Handlers could just call notifyUpdate on SettingsStore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda want to keep as much as possible out of the store so it doesn't become a 1000 line monster. Ideally I'd also move a bunch of the watcher stuff out, but this is fine for now I think.

@turt2live turt2live merged commit 2c2685a into develop Feb 27, 2019
@turt2live turt2live deleted the travis/fix-monitored-settings branch February 27, 2019 15:02
su-ex added a commit to SchildiChat/matrix-react-sdk that referenced this pull request Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants