2021-07-13 06:50:08 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import {
|
2021-07-20 11:31:49 +00:00
|
|
|
ADD_REACTION_BUFFER,
|
|
|
|
ADD_REACTION_MESSAGE,
|
|
|
|
FLUSH_REACTION_BUFFER,
|
|
|
|
PUSH_REACTIONS,
|
|
|
|
SEND_REACTIONS,
|
2021-07-13 06:50:08 +00:00
|
|
|
SET_REACTION_QUEUE
|
|
|
|
} from './actionTypes';
|
|
|
|
import { type ReactionEmojiProps } from './constants';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the reaction queue.
|
|
|
|
*
|
|
|
|
* @param {Array} value - The new queue.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function setReactionQueue(value: Array<ReactionEmojiProps>) {
|
|
|
|
return {
|
|
|
|
type: SET_REACTION_QUEUE,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-20 11:31:49 +00:00
|
|
|
|
2021-07-13 06:50:08 +00:00
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Removes a reaction from the queue.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @param {number} uid - Id of the reaction to be removed.
|
2021-07-13 06:50:08 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function removeReaction(uid: number) {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const queue = getState()['features/reactions'].queue;
|
|
|
|
|
|
|
|
dispatch(setReactionQueue(queue.filter(reaction => reaction.uid !== uid)));
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-20 11:31:49 +00:00
|
|
|
|
2021-07-13 06:50:08 +00:00
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Sends the reactions buffer to everyone in the conference.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: SEND_REACTION
|
|
|
|
* }}
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function sendReactions() {
|
2021-07-13 06:50:08 +00:00
|
|
|
return {
|
2021-07-20 11:31:49 +00:00
|
|
|
type: SEND_REACTIONS
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Adds a reaction to the local buffer.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @param {string} reaction - The reaction to be added.
|
|
|
|
* @returns {{
|
|
|
|
* type: ADD_REACTION_BUFFER,
|
|
|
|
* reaction: string
|
|
|
|
* }}
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function addReactionToBuffer(reaction: string) {
|
2021-07-13 06:50:08 +00:00
|
|
|
return {
|
2021-07-20 11:31:49 +00:00
|
|
|
type: ADD_REACTION_BUFFER,
|
|
|
|
reaction
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Clears the reaction buffer.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: FLUSH_REACTION_BUFFER
|
|
|
|
* }}
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function flushReactionBuffer() {
|
|
|
|
return {
|
|
|
|
type: FLUSH_REACTION_BUFFER
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Adds a reaction message to the chat.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @param {string} message - The reaction message.
|
2021-07-13 06:50:08 +00:00
|
|
|
* @returns {{
|
2021-07-20 11:31:49 +00:00
|
|
|
* type: ADD_REACTION_MESSAGE,
|
|
|
|
* message: string
|
2021-07-13 06:50:08 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function addReactionsToChat(message: string) {
|
2021-07-13 06:50:08 +00:00
|
|
|
return {
|
2021-07-20 11:31:49 +00:00
|
|
|
type: ADD_REACTION_MESSAGE,
|
|
|
|
message
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-20 11:31:49 +00:00
|
|
|
* Adds reactions to the animation queue.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2021-07-20 11:31:49 +00:00
|
|
|
* @param {Array} reactions - The reactions to be animated.
|
2021-07-13 06:50:08 +00:00
|
|
|
* @returns {{
|
2021-07-20 11:31:49 +00:00
|
|
|
* type: PUSH_REACTIONS,
|
|
|
|
* reactions: Array
|
2021-07-13 06:50:08 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2021-07-20 11:31:49 +00:00
|
|
|
export function pushReactions(reactions: Array<string>) {
|
2021-07-13 06:50:08 +00:00
|
|
|
return {
|
2021-07-20 11:31:49 +00:00
|
|
|
type: PUSH_REACTIONS,
|
|
|
|
reactions
|
2021-07-13 06:50:08 +00:00
|
|
|
};
|
|
|
|
}
|