2021-07-13 06:50:08 +00:00
|
|
|
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';
|
2022-06-08 07:44:47 +00:00
|
|
|
import { ReactionEmojiProps } from './constants';
|
|
|
|
import { ReactionsAction } from './reducer';
|
2021-07-13 06:50:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the reaction queue.
|
|
|
|
*
|
2022-06-08 07:44:47 +00:00
|
|
|
* @param {Array} queue - The new queue.
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function setReactionQueue(queue: Array<ReactionEmojiProps>): ReactionsAction {
|
2021-07-13 06:50:08 +00:00
|
|
|
return {
|
|
|
|
type: SET_REACTION_QUEUE,
|
2022-06-08 07:44:47 +00:00
|
|
|
queue
|
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
|
|
|
* Removes a reaction from the queue.
|
2021-07-13 06:50:08 +00:00
|
|
|
*
|
2022-06-08 07:44:47 +00:00
|
|
|
* @param {string} uid - Id of the reaction to be removed.
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function removeReaction(uid: string): Function {
|
2021-07-20 11:31:49 +00:00
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const queue = getState()['features/reactions'].queue;
|
|
|
|
|
2022-06-08 07:44:47 +00:00
|
|
|
dispatch(setReactionQueue(queue.filter((reaction: ReactionEmojiProps) => 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
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function sendReactions(): ReactionsAction {
|
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.
|
2021-07-13 06:50:08 +00:00
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function addReactionToBuffer(reaction: string): ReactionsAction {
|
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
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function flushReactionBuffer(): ReactionsAction {
|
2021-07-20 11:31:49 +00:00
|
|
|
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
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function addReactionsToChat(message: string): ReactionsAction {
|
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
|
|
|
*/
|
2022-06-08 07:44:47 +00:00
|
|
|
export function pushReactions(reactions: Array<string>): ReactionsAction {
|
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
|
|
|
};
|
|
|
|
}
|