feat: Adds internal action for editing chat messages.
This commit is contained in:
parent
6159504478
commit
c64d1a97c1
|
@ -33,6 +33,16 @@ export const CLEAR_MESSAGES = 'CLEAR_MESSAGES';
|
||||||
*/
|
*/
|
||||||
export const CLOSE_CHAT = 'CLOSE_CHAT';
|
export const CLOSE_CHAT = 'CLOSE_CHAT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the action which signals to edit chat message.
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* type: EDIT_MESSAGE,
|
||||||
|
* message: Object
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
export const EDIT_MESSAGE = 'EDIT_MESSAGE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the action which signals to display the chat panel.
|
* The type of the action which signals to display the chat panel.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
ADD_MESSAGE,
|
ADD_MESSAGE,
|
||||||
CLEAR_MESSAGES,
|
CLEAR_MESSAGES,
|
||||||
CLOSE_CHAT,
|
CLOSE_CHAT,
|
||||||
|
EDIT_MESSAGE,
|
||||||
SEND_MESSAGE,
|
SEND_MESSAGE,
|
||||||
SET_PRIVATE_MESSAGE_RECIPIENT,
|
SET_PRIVATE_MESSAGE_RECIPIENT,
|
||||||
SET_IS_POLL_TAB_FOCUSED
|
SET_IS_POLL_TAB_FOCUSED
|
||||||
|
@ -41,6 +42,23 @@ export function addMessage(messageDetails: Object) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits an existing chat message.
|
||||||
|
*
|
||||||
|
* @param {Object} message - The chat message to edit/override. The messages will be matched from the state
|
||||||
|
* comparing the messageId.
|
||||||
|
* @returns {{
|
||||||
|
* type: EDIT_MESSAGE,
|
||||||
|
* message: Object
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
|
export function editMessage(message: Object) {
|
||||||
|
return {
|
||||||
|
type: EDIT_MESSAGE,
|
||||||
|
message
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the chat messages in Redux.
|
* Clears the chat messages in Redux.
|
||||||
*
|
*
|
||||||
|
|
|
@ -314,7 +314,7 @@ function _handleReceivedMessage({ dispatch, getState },
|
||||||
// Provide a default for for the case when a message is being
|
// Provide a default for for the case when a message is being
|
||||||
// backfilled for a participant that has left the conference.
|
// backfilled for a participant that has left the conference.
|
||||||
const participant = getParticipantById(state, id) || {};
|
const participant = getParticipantById(state, id) || {};
|
||||||
console.error('receiveeeed from', id, 'breakout:', APP.store.getState()["features/breakout-rooms"]);
|
|
||||||
const localParticipant = getLocalParticipant(getState);
|
const localParticipant = getLocalParticipant(getState);
|
||||||
const displayName = getParticipantDisplayName(state, id);
|
const displayName = getParticipantDisplayName(state, id);
|
||||||
const hasRead = participant.local || isChatOpen;
|
const hasRead = participant.local || isChatOpen;
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { ReducerRegistry } from '../base/redux';
|
import { ReducerRegistry } from '../base/redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ADD_MESSAGE,
|
ADD_MESSAGE,
|
||||||
CLEAR_MESSAGES,
|
CLEAR_MESSAGES,
|
||||||
CLOSE_CHAT,
|
CLOSE_CHAT,
|
||||||
|
EDIT_MESSAGE,
|
||||||
OPEN_CHAT,
|
OPEN_CHAT,
|
||||||
SET_PRIVATE_MESSAGE_RECIPIENT,
|
SET_PRIVATE_MESSAGE_RECIPIENT,
|
||||||
SET_IS_POLL_TAB_FOCUSED
|
SET_IS_POLL_TAB_FOCUSED
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
|
||||||
|
|
||||||
const DEFAULT_STATE = {
|
const DEFAULT_STATE = {
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
|
@ -65,6 +67,30 @@ ReducerRegistry.register('features/chat', (state = DEFAULT_STATE, action) => {
|
||||||
messages: []
|
messages: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case EDIT_MESSAGE: {
|
||||||
|
let found = false;
|
||||||
|
const newMessage = action.message;
|
||||||
|
const messages = state.messages.map(m => {
|
||||||
|
if (m.messageId === newMessage.messageId) {
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
return newMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m;
|
||||||
|
});
|
||||||
|
|
||||||
|
// no change
|
||||||
|
if (!found) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
messages
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
case SET_PRIVATE_MESSAGE_RECIPIENT:
|
case SET_PRIVATE_MESSAGE_RECIPIENT:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
Loading…
Reference in New Issue