Remove channels to simplify subscription

Make subscriptions either on or off to greatly simplify the logic of
subscribing to events.
This commit is contained in:
Hornwitser committed 2023-12-03 20:32:48 +01:00
1 parent a2eb98ac93
commit 58914042cc
11 files changed
+51 -279

No files matched your search

+5 -2
View File
@@ -79,12 +79,15 @@ export function useUser(name: string): [RawUserState, () => void] {
updateUser();
function updateHandler(newUser: lib.User) {
if (newUser.name !== name) {
return;
}
setUser({ ...newUser, present: true });
}
control.userUpdate.subscribeToChannel(name, updateHandler);
control.userUpdate.subscribe(updateHandler);
return () => {
control.userUpdate.unsubscribeFromChannel(name, updateHandler);
control.userUpdate.unsubscribe(updateHandler);
};
}, [name]);