Merge pull request #17950 from Scroody/I-17888

Fix: Send to chat presentation not having unread notification
This commit is contained in:
Ramón Souza 2023-05-19 14:44:00 -03:00 committed by GitHub
commit 0eeeaf9833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 60 deletions

View File

@ -7,7 +7,8 @@ export default async function sendExportedPresentationChatMsg(meetingId, present
const CHAT_CONFIG = Meteor.settings.public.chat; const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id; const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
const PUBLIC_CHAT_SYSTEM_ID = CHAT_CONFIG.system_userid; const PUBLIC_CHAT_SYSTEM_ID = CHAT_CONFIG.system_userid;
const CHAT_EXPORTED_PRESENTATION_MESSAGE = CHAT_CONFIG.system_messages_keys.chat_exported_presentation; const CHAT_EXPORTED_PRESENTATION_MESSAGE = CHAT_CONFIG.system_messages_keys
.chat_exported_presentation;
const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system; const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system;
const pres = await Presentations.findOneAsync({ meetingId, id: presentationId }); const pres = await Presentations.findOneAsync({ meetingId, id: presentationId });

View File

@ -180,8 +180,12 @@ const ChatAlert = (props) => {
const createPollMessage = () => ( const createPollMessage = () => (
<Styled.PushMessageContent> <Styled.PushMessageContent>
<Styled.UserNameMessage>{intl.formatMessage(intlMessages.pollResults)}</Styled.UserNameMessage> <Styled.UserNameMessage>
<Styled.ContentMessagePoll>{intl.formatMessage(intlMessages.pollResultsClick)}</Styled.ContentMessagePoll> {intl.formatMessage(intlMessages.pollResults)}
</Styled.UserNameMessage>
<Styled.ContentMessagePoll>
{intl.formatMessage(intlMessages.pollResultsClick)}
</Styled.ContentMessagePoll>
</Styled.PushMessageContent> </Styled.PushMessageContent>
); );

View File

@ -66,6 +66,11 @@ class TimeWindowChatItem extends PureComponent {
}; };
} }
componentWillMount() {
ChatLogger.debug('TimeWindowChatItem::componentWillMount::props', { ...this.props });
ChatLogger.debug('TimeWindowChatItem::componentWillMount::state', { ...this.state });
}
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { height, forceCacheUpdate, index } = this.props; const { height, forceCacheUpdate, index } = this.props;
const elementHeight = this.itemRef ? this.itemRef.clientHeight : null; const elementHeight = this.itemRef ? this.itemRef.clientHeight : null;
@ -81,11 +86,6 @@ class TimeWindowChatItem extends PureComponent {
ChatLogger.debug('TimeWindowChatItem::componentDidUpdate::state', { ...this.state }, { ...prevState }); ChatLogger.debug('TimeWindowChatItem::componentDidUpdate::state', { ...this.state }, { ...prevState });
} }
componentWillMount() {
ChatLogger.debug('TimeWindowChatItem::componentWillMount::props', { ...this.props });
ChatLogger.debug('TimeWindowChatItem::componentWillMount::state', { ...this.state });
}
componentWillUnmount() { componentWillUnmount() {
ChatLogger.debug('TimeWindowChatItem::componentWillUnmount::props', { ...this.props }); ChatLogger.debug('TimeWindowChatItem::componentWillUnmount::props', { ...this.props });
ChatLogger.debug('TimeWindowChatItem::componentWillUnmount::state', { ...this.state }); ChatLogger.debug('TimeWindowChatItem::componentWillUnmount::state', { ...this.state });
@ -322,8 +322,8 @@ class TimeWindowChatItem extends PureComponent {
<Styled.PollIcon iconName="download" /> <Styled.PollIcon iconName="download" />
</UserAvatar> </UserAvatar>
</Styled.AvatarWrapper> </Styled.AvatarWrapper>
<Styled.Content <Styled.Content
data-test="downloadPresentationContainer"> data-test="downloadPresentationContainer">
<Styled.Meta> <Styled.Meta>
<Styled.Time dateTime={dateTime} style={{ margin: 0 }}> <Styled.Time dateTime={dateTime} style={{ margin: 0 }}>
<FormattedTime value={dateTime} /> <FormattedTime value={dateTime} />
@ -362,7 +362,7 @@ class TimeWindowChatItem extends PureComponent {
const { const {
systemMessage, systemMessage,
} = this.props; } = this.props;
ChatLogger.debug('TimeWindowChatItem::render', {...this.props}); ChatLogger.debug('TimeWindowChatItem::render', { ...this.props });
if (systemMessage) { if (systemMessage) {
return this.renderSystemMessage(); return this.renderSystemMessage();
} }

View File

@ -14,6 +14,8 @@ const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id; const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id;
const PUBLIC_GROUP_CHAT_KEY = CHAT_CONFIG.public_group_id; const PUBLIC_GROUP_CHAT_KEY = CHAT_CONFIG.public_group_id;
const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system; const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system;
const CHAT_EXPORTED_PRESENTATION_MESSAGE = CHAT_CONFIG.system_messages_keys
.chat_exported_presentation;
const CHAT_POLL_RESULTS_MESSAGE = CHAT_CONFIG.system_messages_keys.chat_poll_result; const CHAT_POLL_RESULTS_MESSAGE = CHAT_CONFIG.system_messages_keys.chat_poll_result;
const CLOSED_CHAT_LIST_KEY = 'closedChatList'; const CLOSED_CHAT_LIST_KEY = 'closedChatList';
@ -54,7 +56,7 @@ export const ChatContext = createContext();
const removedMessagesReadState = {}; const removedMessagesReadState = {};
const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY) => { const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY) => {
const timeWindow = generateTimeWindow(msg.timestamp); const timeWindow = generateTimeWindow(msg.timestamp);
const userId = msg.sender; const userId = msg.sender;
const keyName = userId + '-' + timeWindow; const keyName = userId + '-' + timeWindow;
@ -80,12 +82,12 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
], ],
} }
}; };
return [tempGroupMessage, msg.sender, indexValue, msg.senderName]; return [tempGroupMessage, msg.sender, indexValue, msg.senderName];
}; };
let stateMessages = state[msg.chatId]; let stateMessages = state[msg.chatId];
if (!stateMessages) { if (!stateMessages) {
if (msg.chatId === getGroupChatId()) { if (msg.chatId === getGroupChatId()) {
state[msg.chatId] = { state[msg.chatId] = {
@ -93,7 +95,7 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
chatIndexes: {}, chatIndexes: {},
preJoinMessages: {}, preJoinMessages: {},
posJoinMessages: {}, posJoinMessages: {},
synced:true, synced: true,
unreadTimeWindows: new Set(), unreadTimeWindows: new Set(),
unreadCount: 0, unreadCount: 0,
}; };
@ -102,7 +104,7 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
count: 0, count: 0,
lastSender: '', lastSender: '',
lastSenderName: '', lastSenderName: '',
synced:true, synced: true,
chatIndexes: {}, chatIndexes: {},
messageGroups: {}, messageGroups: {},
unreadTimeWindows: new Set(), unreadTimeWindows: new Set(),
@ -113,7 +115,7 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
stateMessages = state[msg.chatId]; stateMessages = state[msg.chatId];
} }
const forPublicChat = msg.timestamp < getLoginTime() ? stateMessages.preJoinMessages : stateMessages.posJoinMessages; const forPublicChat = msg.timestamp < getLoginTime() ? stateMessages.preJoinMessages : stateMessages.posJoinMessages;
const forPrivateChat = stateMessages.messageGroups; const forPrivateChat = stateMessages.messageGroups;
const messageGroups = msg.chatId === getGroupChatId() ? forPublicChat : forPrivateChat; const messageGroups = msg.chatId === getGroupChatId() ? forPublicChat : forPrivateChat;
@ -130,7 +132,7 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
stateMessages.chatIndexes[keyName] = newIndex; stateMessages.chatIndexes[keyName] = newIndex;
stateMessages.lastTimewindow = keyName + '-' + newIndex; stateMessages.lastTimewindow = keyName + '-' + newIndex;
ChatLogger.trace('ChatContext::formatMsg::msgBuilder::tempGroupMessage', tempGroupMessage); ChatLogger.trace('ChatContext::formatMsg::msgBuilder::tempGroupMessage', tempGroupMessage);
const messageGroupsKeys = Object.keys(tempGroupMessage); const messageGroupsKeys = Object.keys(tempGroupMessage);
messageGroupsKeys.forEach(key => { messageGroupsKeys.forEach(key => {
messageGroups[key] = tempGroupMessage[key]; messageGroups[key] = tempGroupMessage[key];
@ -138,11 +140,15 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
message.messageType = msgType; message.messageType = msgType;
const previousMessage = message.timestamp <= getLoginTime(); const previousMessage = message.timestamp <= getLoginTime();
const amIPresenter = UserService.isUserPresenter(Auth.userID); const amIPresenter = UserService.isUserPresenter(Auth.userID);
const shouldAddPollResultMessage = message.id.includes(CHAT_POLL_RESULTS_MESSAGE) && !amIPresenter; const shouldAddPresentationExportMessage = message.id
.includes(CHAT_EXPORTED_PRESENTATION_MESSAGE) && !amIPresenter;
const shouldAddPollResultMessage = message.id
.includes(CHAT_POLL_RESULTS_MESSAGE) && !amIPresenter;
if ( if (
!previousMessage !previousMessage
&& message.sender !== Auth.userID && message.sender !== Auth.userID
&& (!message.id.startsWith(SYSTEM_CHAT_TYPE) || shouldAddPollResultMessage) && (!message.id.startsWith(SYSTEM_CHAT_TYPE) || shouldAddPollResultMessage
|| shouldAddPresentationExportMessage)
&& !message.read && !message.read
) { ) {
stateMessages.unreadTimeWindows.add(key); stateMessages.unreadTimeWindows.add(key);
@ -174,7 +180,7 @@ const generateStateWithNewMessage = (msg, state, msgType = MESSAGE_TYPES.HISTORY
return state; return state;
} }
const reducer = (state, action) => { const reducer = (state, action) => {
switch (action.type) { switch (action.type) {
case ACTIONS.TEST: { case ACTIONS.TEST: {
ChatLogger.debug(ACTIONS.TEST); ChatLogger.debug(ACTIONS.TEST);
@ -185,18 +191,18 @@ const reducer = (state, action) => {
} }
case ACTIONS.ADDED: { case ACTIONS.ADDED: {
ChatLogger.debug(ACTIONS.ADDED); ChatLogger.debug(ACTIONS.ADDED);
const batchMsgs = action.value; const batchMsgs = action.value;
const closedChatsToOpen = new Set(); const closedChatsToOpen = new Set();
const currentClosedChats = Storage.getItem(CLOSED_CHAT_LIST_KEY) || []; const currentClosedChats = Storage.getItem(CLOSED_CHAT_LIST_KEY) || [];
const loginTime = getLoginTime(); const loginTime = getLoginTime();
const newState = batchMsgs.reduce((acc, i)=> { const newState = batchMsgs.reduce((acc, i) => {
const message = i; const message = i;
const chatId = message.chatId; const chatId = message.chatId;
if ( if (
chatId !== PUBLIC_GROUP_CHAT_KEY chatId !== PUBLIC_GROUP_CHAT_KEY
&& message.timestamp > loginTime && message.timestamp > loginTime
&& currentClosedChats.includes(chatId) ){ && currentClosedChats.includes(chatId)) {
closedChatsToOpen.add(chatId) closedChatsToOpen.add(chatId)
} }
return generateStateWithNewMessage(message, acc, action.messageType); return generateStateWithNewMessage(message, acc, action.messageType);
@ -207,7 +213,7 @@ const reducer = (state, action) => {
Storage.setItem(CLOSED_CHAT_LIST_KEY, closedChats); Storage.setItem(CLOSED_CHAT_LIST_KEY, closedChats);
} }
// const newState = generateStateWithNewMessage(action.value, state); // const newState = generateStateWithNewMessage(action.value, state);
return {...newState}; return { ...newState };
} }
case ACTIONS.CHANGED: { case ACTIONS.CHANGED: {
return { return {
@ -217,7 +223,7 @@ const reducer = (state, action) => {
} }
case ACTIONS.REMOVED: { case ACTIONS.REMOVED: {
ChatLogger.debug(ACTIONS.REMOVED); ChatLogger.debug(ACTIONS.REMOVED);
if (state[PUBLIC_GROUP_CHAT_KEY]){ if (state[PUBLIC_GROUP_CHAT_KEY]) {
state[PUBLIC_GROUP_CHAT_KEY] = { state[PUBLIC_GROUP_CHAT_KEY] = {
count: 0, count: 0,
lastSender: '', lastSender: '',
@ -240,15 +246,15 @@ const reducer = (state, action) => {
const selectedChatId = chatId === PUBLIC_CHAT_KEY ? PUBLIC_GROUP_CHAT_KEY : chatId; const selectedChatId = chatId === PUBLIC_CHAT_KEY ? PUBLIC_GROUP_CHAT_KEY : chatId;
const chat = state[selectedChatId]; const chat = state[selectedChatId];
if (!chat) return state; if (!chat) return state;
['posJoinMessages','preJoinMessages','messageGroups'].forEach( messageGroupName => { ['posJoinMessages', 'preJoinMessages', 'messageGroups'].forEach(messageGroupName => {
const messageGroup = chat[messageGroupName]; const messageGroup = chat[messageGroupName];
if (messageGroup){ if (messageGroup) {
const timeWindowsids = Object.keys(messageGroup); const timeWindowsids = Object.keys(messageGroup);
timeWindowsids.forEach( timeWindowId => { timeWindowsids.forEach(timeWindowId => {
const timeWindow = messageGroup[timeWindowId]; const timeWindow = messageGroup[timeWindowId];
if(timeWindow) { if (timeWindow) {
if (!timeWindow.read) { if (!timeWindow.read) {
if (timeWindow.lastTimestamp <= timestamp){ if (timeWindow.lastTimestamp <= timestamp) {
newState[selectedChatId].unreadTimeWindows.delete(timeWindowId); newState[selectedChatId].unreadTimeWindows.delete(timeWindowId);
newState[selectedChatId][messageGroupName][timeWindowId] = { newState[selectedChatId][messageGroupName][timeWindowId] = {
@ -256,7 +262,7 @@ const reducer = (state, action) => {
read: true, read: true,
}; };
newState[selectedChatId] = { newState[selectedChatId] = {
...newState[selectedChatId], ...newState[selectedChatId],
}; };
@ -279,7 +285,7 @@ const reducer = (state, action) => {
const { chatId } = action; const { chatId } = action;
const newState = { ...state }; const newState = { ...state };
if (!newState[chatId]){ if (!newState[chatId]) {
newState[chatId] = { newState[chatId] = {
count: 0, count: 0,
lastSender: '', lastSender: '',
@ -304,29 +310,29 @@ const reducer = (state, action) => {
const newState = { ...state }; const newState = { ...state };
const chatIds = Object.keys(newState); const chatIds = Object.keys(newState);
chatIds.forEach((chatId) => { chatIds.forEach((chatId) => {
newState[chatId] = chatId === PUBLIC_GROUP_CHAT_KEY ? newState[chatId] = chatId === PUBLIC_GROUP_CHAT_KEY ?
{ {
count: 0, count: 0,
lastSender: '', lastSender: '',
chatIndexes: {}, chatIndexes: {},
preJoinMessages: {}, preJoinMessages: {},
posJoinMessages: {}, posJoinMessages: {},
syncing: false, syncing: false,
syncedPercent: 0, syncedPercent: 0,
unreadTimeWindows: new Set(), unreadTimeWindows: new Set(),
unreadCount: 0, unreadCount: 0,
} }
: :
{ {
count: 0, count: 0,
lastSender: '', lastSender: '',
chatIndexes: {}, chatIndexes: {},
messageGroups: {}, messageGroups: {},
syncing: false, syncing: false,
syncedPercent: 0, syncedPercent: 0,
unreadTimeWindows: new Set(), unreadTimeWindows: new Set(),
unreadCount: 0, unreadCount: 0,
}; };
}); });
return newState; return newState;
} }
@ -338,11 +344,11 @@ const reducer = (state, action) => {
const chatIds = Object.keys(newState); const chatIds = Object.keys(newState);
chatIds.forEach((chatId) => { chatIds.forEach((chatId) => {
const chat = newState[chatId]; const chat = newState[chatId];
['posJoinMessages','messageGroups'].forEach((group)=> { ['posJoinMessages', 'messageGroups'].forEach((group) => {
const messages = chat[group]; const messages = chat[group];
if (messages) { if (messages) {
const timeWindowIds = Object.keys(messages); const timeWindowIds = Object.keys(messages);
timeWindowIds.forEach((timeWindowId)=> { timeWindowIds.forEach((timeWindowId) => {
const timeWindow = messages[timeWindowId]; const timeWindow = messages[timeWindowId];
if (timeWindow.messageType === MESSAGE_TYPES.STREAM) { if (timeWindow.messageType === MESSAGE_TYPES.STREAM) {
chat.unreadTimeWindows.delete(timeWindowId); chat.unreadTimeWindows.delete(timeWindowId);