Fix unread indication for scheduled messages (#1030)
This commit is contained in:
parent
8f886b2cb9
commit
4e8381f997
@ -151,6 +151,7 @@ export function buildApiMessageWithChatId(chatId: number, mtpMessage: UniversalM
|
|||||||
const groupedId = mtpMessage.groupedId && mtpMessage.groupedId.toString();
|
const groupedId = mtpMessage.groupedId && mtpMessage.groupedId.toString();
|
||||||
const isInAlbum = Boolean(groupedId) && !(content.document || content.audio);
|
const isInAlbum = Boolean(groupedId) && !(content.document || content.audio);
|
||||||
const shouldHideKeyboardButtons = mtpMessage.replyMarkup instanceof GramJs.ReplyKeyboardHide;
|
const shouldHideKeyboardButtons = mtpMessage.replyMarkup instanceof GramJs.ReplyKeyboardHide;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: mtpMessage.id,
|
id: mtpMessage.id,
|
||||||
chatId,
|
chatId,
|
||||||
@ -159,6 +160,7 @@ export function buildApiMessageWithChatId(chatId: number, mtpMessage: UniversalM
|
|||||||
date: mtpMessage.date,
|
date: mtpMessage.date,
|
||||||
senderId: fromId || (mtpMessage.out && mtpMessage.post && currentUserId) || chatId,
|
senderId: fromId || (mtpMessage.out && mtpMessage.post && currentUserId) || chatId,
|
||||||
views: mtpMessage.views,
|
views: mtpMessage.views,
|
||||||
|
isFromScheduled: mtpMessage.fromScheduled,
|
||||||
...(replyToMsgId && { replyToMessageId: replyToMsgId }),
|
...(replyToMsgId && { replyToMessageId: replyToMsgId }),
|
||||||
...(replyToTopId && { replyToTopMessageId: replyToTopId }),
|
...(replyToTopId && { replyToTopMessageId: replyToTopId }),
|
||||||
...(forwardInfo && { forwardInfo }),
|
...(forwardInfo && { forwardInfo }),
|
||||||
|
|||||||
@ -239,6 +239,7 @@ export interface ApiMessage {
|
|||||||
adminTitle?: string;
|
adminTitle?: string;
|
||||||
isScheduled?: boolean;
|
isScheduled?: boolean;
|
||||||
shouldHideKeyboardButtons?: boolean;
|
shouldHideKeyboardButtons?: boolean;
|
||||||
|
isFromScheduled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiThreadInfo {
|
export interface ApiThreadInfo {
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
&.mention, &.unread:not(.muted) {
|
&.mention, &.unread:not(.muted) {
|
||||||
background: var(--color-green);
|
background: var(--color-green);
|
||||||
|
color: var(--color-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.pinned:not(.unread) {
|
&.pinned:not(.unread) {
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import {
|
|||||||
selectCommonBoxChatId,
|
selectCommonBoxChatId,
|
||||||
selectIsChatListed,
|
selectIsChatListed,
|
||||||
selectChatListType,
|
selectChatListType,
|
||||||
|
selectCurrentMessageList,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
|
|
||||||
const TYPING_STATUS_CLEAR_DELAY = 6000; // 6 seconds
|
const TYPING_STATUS_CLEAR_DELAY = 6000; // 6 seconds
|
||||||
@ -89,7 +90,10 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'newMessage': {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -523,14 +523,18 @@ export function selectFirstUnreadId(global: GlobalState, chatId: number, threadI
|
|||||||
const lastReadId = selectRealLastReadId(global, chatId, threadId);
|
const lastReadId = selectRealLastReadId(global, chatId, threadId);
|
||||||
|
|
||||||
if (outlyingIds) {
|
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) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listedIds) {
|
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) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user