2019-01-13 19:34:38 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-01-01 21:19:34 +00:00
|
|
|
import {
|
|
|
|
ADD_MESSAGE,
|
|
|
|
CLEAR_MESSAGES,
|
|
|
|
SEND_MESSAGE,
|
|
|
|
TOGGLE_CHAT
|
|
|
|
} from './actionTypes';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a chat message to the collection of messages.
|
|
|
|
*
|
2018-08-29 17:24:25 +00:00
|
|
|
* @param {Object} messageDetails - The chat message to save.
|
|
|
|
* @param {string} messageDetails.displayName - The displayName of the
|
|
|
|
* participant that authored the message.
|
|
|
|
* @param {boolean} messageDetails.hasRead - Whether or not to immediately mark
|
|
|
|
* the message as read.
|
|
|
|
* @param {string} messageDetails.message - The received message to display.
|
|
|
|
* @param {string} messageDetails.messageType - The kind of message, such as
|
|
|
|
* "error" or "local" or "remote".
|
|
|
|
* @param {string} messageDetails.timestamp - A timestamp to display for when
|
|
|
|
* the message was received.
|
2018-03-07 00:28:19 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: ADD_MESSAGE,
|
2018-08-29 17:24:25 +00:00
|
|
|
* displayName: string,
|
2018-03-07 00:28:19 +00:00
|
|
|
* hasRead: boolean,
|
|
|
|
* message: string,
|
2018-08-29 17:24:25 +00:00
|
|
|
* messageType: string,
|
2018-03-07 00:28:19 +00:00
|
|
|
* timestamp: string,
|
|
|
|
* }}
|
|
|
|
*/
|
2019-01-13 19:34:38 +00:00
|
|
|
export function addMessage(messageDetails: Object) {
|
2018-03-07 00:28:19 +00:00
|
|
|
return {
|
|
|
|
type: ADD_MESSAGE,
|
2018-08-29 17:24:25 +00:00
|
|
|
...messageDetails
|
2018-03-07 00:28:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-01-01 21:19:34 +00:00
|
|
|
/**
|
2019-01-13 19:34:38 +00:00
|
|
|
* Clears the chat messages in Redux.
|
2019-01-01 21:19:34 +00:00
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: CLEAR_MESSAGES
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function clearMessages() {
|
|
|
|
return {
|
|
|
|
type: CLEAR_MESSAGES
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
2018-08-29 17:24:25 +00:00
|
|
|
* Sends a chat message to everyone in the conference.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
2018-08-29 17:24:25 +00:00
|
|
|
* @param {string} message - The chat message to send out.
|
|
|
|
* @returns {{
|
|
|
|
* type: SEND_MESSAGE,
|
|
|
|
* message: string
|
|
|
|
* }}
|
2018-03-07 00:28:19 +00:00
|
|
|
*/
|
2019-01-13 19:34:38 +00:00
|
|
|
export function sendMessage(message: string) {
|
2018-08-29 17:24:25 +00:00
|
|
|
return {
|
|
|
|
type: SEND_MESSAGE,
|
|
|
|
message
|
2018-03-07 00:28:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-29 17:24:25 +00:00
|
|
|
* Toggles display of the chat side panel.
|
2018-03-07 00:28:19 +00:00
|
|
|
*
|
|
|
|
* @returns {{
|
2018-08-29 17:24:25 +00:00
|
|
|
* type: TOGGLE_CHAT
|
2018-03-07 00:28:19 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-08-29 17:24:25 +00:00
|
|
|
export function toggleChat() {
|
2018-03-07 00:28:19 +00:00
|
|
|
return {
|
2018-08-29 17:24:25 +00:00
|
|
|
type: TOGGLE_CHAT
|
2018-03-07 00:28:19 +00:00
|
|
|
};
|
|
|
|
}
|