Polls: sync push rules on changes to account_data (#10287)

* basic sync setup

* formatting

* get loudest value for synced rules

* more types

* test synced rules in notifications settings

* type fixes

* noimplicitany fixes

* remove debug

* tidying

* extract updatePushRuleActions fn to utils

* extract update synced rules

* just synchronise in one place?

* monitor account data changes AND trigger changes sync in notifications form

* lint

* setup LoggedInView test with enough mocks

* test rule syncing in LoggedInView

* strict fixes

* more comments

* one more comment
This commit is contained in:
Kerry 2023-03-09 13:20:06 +13:00 committed by GitHub
parent 4c6f8ad122
commit cef821c21b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 525 additions and 51 deletions

View file

@ -70,6 +70,7 @@ import { IConfigOptions } from "../../IConfigOptions";
import LeftPanelLiveShareWarning from "../views/beacon/LeftPanelLiveShareWarning";
import { UserOnboardingPage } from "../views/user-onboarding/UserOnboardingPage";
import { PipContainer } from "./PipContainer";
import { monitorSyncedPushRules } from "../../utils/pushRules/monitorSyncedPushRules";
// We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity.
@ -165,6 +166,8 @@ class LoggedInView extends React.Component<IProps, IState> {
this.updateServerNoticeEvents();
this._matrixClient.on(ClientEvent.AccountData, this.onAccountData);
// check push rules on start up as well
monitorSyncedPushRules(this._matrixClient.getAccountData("m.push_rules"), this._matrixClient);
this._matrixClient.on(ClientEvent.Sync, this.onSync);
// Call `onSync` with the current state as well
this.onSync(this._matrixClient.getSyncState(), null, this._matrixClient.getSyncStateData());
@ -279,6 +282,7 @@ class LoggedInView extends React.Component<IProps, IState> {
if (event.getType() === "m.ignored_user_list") {
dis.dispatch({ action: "ignore_state_changed" });
}
monitorSyncedPushRules(event, this._matrixClient);
};
private onCompactLayoutChanged = (): void => {