mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-26 11:38:37 +00:00
Refactor to allow dispatching of two kinds of Actions
They are: 1. The existing type of Action, Objects with an `action` type. 1. Asyncronous Actions, functions that accept a `dispatch` argument, which can be used to dispatch Actions asyncronously.
This commit is contained in:
@@ -15,14 +15,13 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import Analytics from '../Analytics';
|
||||
import { createPromiseActionCreator } from './actionCreators';
|
||||
import { asyncAction } from './actionCreators';
|
||||
import TagOrderStore from '../stores/TagOrderStore';
|
||||
|
||||
const TagOrderActions = {};
|
||||
|
||||
TagOrderActions.commitTagOrdering = createPromiseActionCreator(
|
||||
'TagOrderActions.commitTagOrdering',
|
||||
(matrixClient) => {
|
||||
TagOrderActions.commitTagOrdering = function(matrixClient) {
|
||||
return asyncAction('TagOrderActions.commitTagOrdering', () => {
|
||||
// Only commit tags if the state is ready, i.e. not null
|
||||
const tags = TagOrderStore.getOrderedTags();
|
||||
if (!tags) {
|
||||
@@ -31,7 +30,7 @@ TagOrderActions.commitTagOrdering = createPromiseActionCreator(
|
||||
|
||||
Analytics.trackEvent('TagOrderActions', 'commitTagOrdering');
|
||||
return matrixClient.setAccountData('im.vector.web.tag_ordering', {tags});
|
||||
},
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export default TagOrderActions;
|
||||
|
||||
Reference in New Issue
Block a user