Fix unread indication for scheduled messages (#1030)

This commit is contained in:
Alexander Zinchuk 2021-04-22 12:09:06 +03:00
parent 8f886b2cb9
commit 4e8381f997
5 changed files with 15 additions and 3 deletions

View File

@ -151,6 +151,7 @@ export function buildApiMessageWithChatId(chatId: number, mtpMessage: UniversalM
const groupedId = mtpMessage.groupedId && mtpMessage.groupedId.toString();
const isInAlbum = Boolean(groupedId) && !(content.document || content.audio);
const shouldHideKeyboardButtons = mtpMessage.replyMarkup instanceof GramJs.ReplyKeyboardHide;
return {
id: mtpMessage.id,
chatId,
@ -159,6 +160,7 @@ export function buildApiMessageWithChatId(chatId: number, mtpMessage: UniversalM
date: mtpMessage.date,
senderId: fromId || (mtpMessage.out && mtpMessage.post && currentUserId) || chatId,
views: mtpMessage.views,
isFromScheduled: mtpMessage.fromScheduled,
...(replyToMsgId && { replyToMessageId: replyToMsgId }),
...(replyToTopId && { replyToTopMessageId: replyToTopId }),
...(forwardInfo && { forwardInfo }),

View File

@ -239,6 +239,7 @@ export interface ApiMessage {
adminTitle?: string;
isScheduled?: boolean;
shouldHideKeyboardButtons?: boolean;
isFromScheduled?: boolean;
}
export interface ApiThreadInfo {

View File

@ -41,6 +41,7 @@
&.mention, &.unread:not(.muted) {
background: var(--color-green);
color: var(--color-white);
}
&.pinned:not(.unread) {

View File

@ -15,6 +15,7 @@ import {
selectCommonBoxChatId,
selectIsChatListed,
selectChatListType,
selectCurrentMessageList,
} from '../../selectors';
const TYPING_STATUS_CLEAR_DELAY = 6000; // 6 seconds
@ -89,7 +90,10 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
}
case 'newMessage': {
if (update.message.senderId === global.currentUserId) {
const { message } = update;
const { chatId: currentChatId } = selectCurrentMessageList(global) || {};
if (message.chatId === currentChatId || (message.senderId === global.currentUserId && !message.isFromScheduled)) {
return;
}

View File

@ -523,14 +523,18 @@ export function selectFirstUnreadId(global: GlobalState, chatId: number, threadI
const lastReadId = selectRealLastReadId(global, chatId, threadId);
if (outlyingIds) {
const found = outlyingIds.find((id) => !lastReadId || (id > lastReadId && byId[id] && !byId[id].isOutgoing));
const found = outlyingIds.find((id) => {
return !lastReadId || (id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled));
});
if (found) {
return found;
}
}
if (listedIds) {
const found = listedIds.find((id) => !lastReadId || (id > lastReadId && byId[id] && !byId[id].isOutgoing));
const found = listedIds.find((id) => {
return !lastReadId || (id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled));
});
if (found) {
return found;
}