diff --git a/src/actions/TagOrderActions.js b/src/actions/TagOrderActions.js new file mode 100644 index 0000000000..d98cf28ca8 --- /dev/null +++ b/src/actions/TagOrderActions.js @@ -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; diff --git a/src/components/structures/TagPanel.js b/src/components/structures/TagPanel.js index ae86bef4c1..127a220b26 100644 --- a/src/components/structures/TagPanel.js +++ b/src/components/structures/TagPanel.js @@ -22,6 +22,7 @@ import FlairStore from '../../stores/FlairStore'; import TagOrderStore from '../../stores/TagOrderStore'; import GroupActions from '../../actions/GroupActions'; +import TagOrderActions from '../../actions/TagOrderActions'; import sdk from '../../index'; import dis from '../../dispatcher'; @@ -91,6 +92,10 @@ const TagPanel = React.createClass({ dis.dispatch({action: 'view_create_group'}); }, + onTagTileEndDrag() { + TagOrderActions.commitTagOrdering(this.context.matrixClient); + }, + render() { const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); const TintableSvg = sdk.getComponent('elements.TintableSvg'); @@ -101,6 +106,7 @@ const TagPanel = React.createClass({ key={groupProfile.groupId + '_' + index} groupProfile={groupProfile} selected={this.state.selectedTags.includes(groupProfile.groupId)} + onEndDrag={this.onTagTileEndDrag} />; }); return