mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-25 11:13:41 +00:00
Handle accountData events from TagOrderStore
This introduces a generic way to register certain events emitted by the js-sdk as those that should be propagated through as dispatched actions. This allows the store to treat the js-sdk as the "Server" in the Flux data flow model. It also allows for stores to not be aware specifically of the matrix client if they are only reading from it.
This commit is contained in:
@@ -41,17 +41,14 @@ class TagOrderStore extends Store {
|
||||
|
||||
__onDispatch(payload) {
|
||||
switch (payload.action) {
|
||||
// Get ordering from account data, once the client has synced
|
||||
case 'sync_state':
|
||||
if (payload.prevState === "PREPARED" && payload.state === "SYNCING") {
|
||||
const accountDataEvent = MatrixClientPeg.get().getAccountData('im.vector.web.tag_ordering');
|
||||
|
||||
const orderedTags = accountDataEvent && accountDataEvent.getContent() ?
|
||||
accountDataEvent.getContent().tags : null;
|
||||
|
||||
this._setState({orderedTags});
|
||||
}
|
||||
break;
|
||||
// Get ordering from account data
|
||||
case 'MatrixActions.accountData': {
|
||||
if (payload.event_type !== 'im.vector.web.tag_ordering') break;
|
||||
this._setState({
|
||||
orderedTags: payload.event_content ? payload.event_content.tags : null,
|
||||
});
|
||||
break;
|
||||
}
|
||||
// Initialise the state such that if account data is unset, default to joined groups
|
||||
case 'GroupActions.fetchJoinedGroups.success':
|
||||
this._setState({
|
||||
|
||||
Reference in New Issue
Block a user