Move 'commit_tags' to action creator
This commit is contained in:
parent
12515441cd
commit
72550961e5
4 changed files with 40 additions and 9 deletions
33
src/actions/TagOrderActions.js
Normal file
33
src/actions/TagOrderActions.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Analytics from '../Analytics';
|
||||||
|
import { createPromiseActionCreator } from './actionCreators';
|
||||||
|
import TagOrderStore from '../stores/TagOrderStore';
|
||||||
|
|
||||||
|
const TagOrderActions = {};
|
||||||
|
|
||||||
|
TagOrderActions.commitTagOrdering = createPromiseActionCreator(
|
||||||
|
'TagOrderActions.commitTagOrdering',
|
||||||
|
(matrixClient) => {
|
||||||
|
Analytics.trackEvent('TagOrderActions', 'commitTagOrdering');
|
||||||
|
return matrixClient.setAccountData('im.vector.web.tag_ordering', {
|
||||||
|
tags: TagOrderStore.getOrderedTags(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export default TagOrderActions;
|
|
@ -22,6 +22,7 @@ import FlairStore from '../../stores/FlairStore';
|
||||||
import TagOrderStore from '../../stores/TagOrderStore';
|
import TagOrderStore from '../../stores/TagOrderStore';
|
||||||
|
|
||||||
import GroupActions from '../../actions/GroupActions';
|
import GroupActions from '../../actions/GroupActions';
|
||||||
|
import TagOrderActions from '../../actions/TagOrderActions';
|
||||||
|
|
||||||
import sdk from '../../index';
|
import sdk from '../../index';
|
||||||
import dis from '../../dispatcher';
|
import dis from '../../dispatcher';
|
||||||
|
@ -91,6 +92,10 @@ const TagPanel = React.createClass({
|
||||||
dis.dispatch({action: 'view_create_group'});
|
dis.dispatch({action: 'view_create_group'});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onTagTileEndDrag() {
|
||||||
|
TagOrderActions.commitTagOrdering(this.context.matrixClient);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
||||||
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
||||||
|
@ -101,6 +106,7 @@ const TagPanel = React.createClass({
|
||||||
key={groupProfile.groupId + '_' + index}
|
key={groupProfile.groupId + '_' + index}
|
||||||
groupProfile={groupProfile}
|
groupProfile={groupProfile}
|
||||||
selected={this.state.selectedTags.includes(groupProfile.groupId)}
|
selected={this.state.selectedTags.includes(groupProfile.groupId)}
|
||||||
|
onEndDrag={this.onTagTileEndDrag}
|
||||||
/>;
|
/>;
|
||||||
});
|
});
|
||||||
return <div className="mx_TagPanel" onClick={this.onClick}>
|
return <div className="mx_TagPanel" onClick={this.onClick}>
|
||||||
|
|
|
@ -38,9 +38,7 @@ const tagTileSource = {
|
||||||
if (!monitor.didDrop() || !dropResult) {
|
if (!monitor.didDrop() || !dropResult) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dis.dispatch({
|
props.onEndDrag();
|
||||||
action: 'commit_tags',
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {Store} from 'flux/utils';
|
import {Store} from 'flux/utils';
|
||||||
import dis from '../dispatcher';
|
import dis from '../dispatcher';
|
||||||
import Analytics from '../Analytics';
|
|
||||||
import MatrixClientPeg from "../MatrixClientPeg";
|
|
||||||
|
|
||||||
const INITIAL_STATE = {
|
const INITIAL_STATE = {
|
||||||
orderedTags: null,
|
orderedTags: null,
|
||||||
|
@ -71,10 +69,6 @@ class TagOrderStore extends Store {
|
||||||
this._setState({orderedTags});
|
this._setState({orderedTags});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'commit_tags':
|
|
||||||
MatrixClientPeg.get().setAccountData('im.vector.web.tag_ordering', {tags: this._state.orderedTags});
|
|
||||||
Analytics.trackEvent('TagOrderStore', 'commit_tags');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue