Move 'commit_tags' to action creator
							parent
							
								
									12515441cd
								
							
						
					
					
						commit
						72550961e5
					
				|  | @ -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 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 <div className="mx_TagPanel" onClick={this.onClick}> | ||||
|  |  | |||
|  | @ -38,9 +38,7 @@ const tagTileSource = { | |||
|         if (!monitor.didDrop() || !dropResult) { | ||||
|             return; | ||||
|         } | ||||
|         dis.dispatch({ | ||||
|             action: 'commit_tags', | ||||
|         }); | ||||
|         props.onEndDrag(); | ||||
|     }, | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,8 +15,6 @@ limitations under the License. | |||
| */ | ||||
| import {Store} from 'flux/utils'; | ||||
| import dis from '../dispatcher'; | ||||
| import Analytics from '../Analytics'; | ||||
| import MatrixClientPeg from "../MatrixClientPeg"; | ||||
| 
 | ||||
| const INITIAL_STATE = { | ||||
|     orderedTags: null, | ||||
|  | @ -71,10 +69,6 @@ class TagOrderStore extends Store { | |||
|                 this._setState({orderedTags}); | ||||
|             } | ||||
|             break; | ||||
|             case 'commit_tags': | ||||
|                 MatrixClientPeg.get().setAccountData('im.vector.web.tag_ordering', {tags: this._state.orderedTags}); | ||||
|                 Analytics.trackEvent('TagOrderStore', 'commit_tags'); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Luke Barnard
						Luke Barnard