diff --git a/src/api/gramjs/apiBuilders/messages.ts b/src/api/gramjs/apiBuilders/messages.ts index 2ed5ae8fa..dc1422224 100644 --- a/src/api/gramjs/apiBuilders/messages.ts +++ b/src/api/gramjs/apiBuilders/messages.ts @@ -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 }), diff --git a/src/api/types/messages.ts b/src/api/types/messages.ts index 26e0a8961..3923c8263 100644 --- a/src/api/types/messages.ts +++ b/src/api/types/messages.ts @@ -239,6 +239,7 @@ export interface ApiMessage { adminTitle?: string; isScheduled?: boolean; shouldHideKeyboardButtons?: boolean; + isFromScheduled?: boolean; } export interface ApiThreadInfo { diff --git a/src/components/left/main/Badge.scss b/src/components/left/main/Badge.scss index 018739ce8..77a120d72 100644 --- a/src/components/left/main/Badge.scss +++ b/src/components/left/main/Badge.scss @@ -41,6 +41,7 @@ &.mention, &.unread:not(.muted) { background: var(--color-green); + color: var(--color-white); } &.pinned:not(.unread) { diff --git a/src/modules/actions/apiUpdaters/chats.ts b/src/modules/actions/apiUpdaters/chats.ts index 3c2b1d181..d66d875c5 100644 --- a/src/modules/actions/apiUpdaters/chats.ts +++ b/src/modules/actions/apiUpdaters/chats.ts @@ -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; } diff --git a/src/modules/selectors/messages.ts b/src/modules/selectors/messages.ts index e30ff7484..ea9599d0c 100644 --- a/src/modules/selectors/messages.ts +++ b/src/modules/selectors/messages.ts @@ -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; }