summaryrefslogtreecommitdiffstats
path: root/webapp/stores/reaction_store.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-06-18 14:42:32 -0400
committerGitHub <noreply@github.com>2017-06-18 14:42:32 -0400
commitab67f6e257f6e8f08145a02a7b93550f99641be4 (patch)
treed33d1c58a3d229f7e37db58bc2c397ac3806c503 /webapp/stores/reaction_store.jsx
parent0231e95f1c5a8c42ba97875f0d2301815f552974 (diff)
downloadchat-ab67f6e257f6e8f08145a02a7b93550f99641be4.tar.gz
chat-ab67f6e257f6e8f08145a02a7b93550f99641be4.tar.bz2
chat-ab67f6e257f6e8f08145a02a7b93550f99641be4.zip
PLT-6215 Major post list refactor (#6501)
* Major post list refactor * Fix post and thread deletion * Fix preferences not selecting correctly * Fix military time displaying * Fix UP key for editing posts * Fix ESLint error * Various fixes and updates per feedback * Fix for permalink view * Revert to old scrolling method and various fixes * Add floating timestamp, new message indicator, scroll arrows * Update post loading for focus mode and add visibility limit * Fix pinning posts and a react warning * Add loading UI updates from Asaad * Fix refreshing loop * Temporarily bump post visibility limit * Update infinite scrolling * Remove infinite scrolling
Diffstat (limited to 'webapp/stores/reaction_store.jsx')
-rw-r--r--webapp/stores/reaction_store.jsx92
1 files changed, 0 insertions, 92 deletions
diff --git a/webapp/stores/reaction_store.jsx b/webapp/stores/reaction_store.jsx
deleted file mode 100644
index ebebd4374..000000000
--- a/webapp/stores/reaction_store.jsx
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
-import Constants from 'utils/constants.jsx';
-import EventEmitter from 'events';
-
-const ActionTypes = Constants.ActionTypes;
-
-const CHANGE_EVENT = 'changed';
-
-class ReactionStore extends EventEmitter {
- constructor() {
- super();
-
- this.dispatchToken = AppDispatcher.register(this.handleEventPayload.bind(this));
-
- this.reactions = new Map();
-
- this.setMaxListeners(600);
- }
-
- addChangeListener(postId, callback) {
- this.on(CHANGE_EVENT + postId, callback);
- }
-
- removeChangeListener(postId, callback) {
- this.removeListener(CHANGE_EVENT + postId, callback);
- }
-
- emitChange(postId) {
- this.emit(CHANGE_EVENT + postId, postId);
- }
-
- setReactions(postId, reactions) {
- this.reactions.set(postId, reactions);
- }
-
- addReaction(postId, reaction) {
- let reactions = this.getReactions(postId) || [];
-
- // Make sure not to add duplicates
- const existingIndex = reactions.findIndex((existing) => {
- return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
- });
-
- if (existingIndex === -1) {
- reactions = [...reactions, reaction];
- }
-
- this.setReactions(postId, reactions);
- }
-
- removeReaction(postId, reaction) {
- let reactions = this.getReactions(postId) || [];
-
- const existingIndex = reactions.findIndex((existing) => {
- return existing.user_id === reaction.user_id && existing.post_id === reaction.post_id && existing.emoji_name === reaction.emoji_name;
- });
-
- if (existingIndex !== -1) {
- reactions = reactions.slice(0, existingIndex).concat(reactions.slice(existingIndex + 1));
- }
-
- this.setReactions(postId, reactions);
- }
-
- getReactions(postId) {
- return this.reactions.get(postId);
- }
-
- handleEventPayload(payload) {
- const action = payload.action;
-
- switch (action.type) {
- case ActionTypes.RECEIVED_REACTIONS:
- this.setReactions(action.postId, action.reactions);
- this.emitChange(action.postId);
- break;
- case ActionTypes.ADDED_REACTION:
- this.addReaction(action.postId, action.reaction);
- this.emitChange(action.postId);
- break;
- case ActionTypes.REMOVED_REACTION:
- this.removeReaction(action.postId, action.reaction);
- this.emitChange(action.postId);
- break;
- }
- }
-}
-
-export default new ReactionStore();