Chat: Fix unreads when using other device (#6063)
This commit is contained in:
parent
fca7afe72a
commit
f32d327622
@ -437,7 +437,7 @@ export function buildLocalMessage(
|
|||||||
}),
|
}),
|
||||||
date: scheduledAt || Math.round(Date.now() / 1000) + getServerTimeOffset(),
|
date: scheduledAt || Math.round(Date.now() / 1000) + getServerTimeOffset(),
|
||||||
isOutgoing: !isChannel,
|
isOutgoing: !isChannel,
|
||||||
senderId: sendAs?.id || currentUserId,
|
senderId: chat.type !== 'chatTypePrivate' ? (sendAs?.id || currentUserId) : undefined,
|
||||||
replyInfo: resultReplyInfo,
|
replyInfo: resultReplyInfo,
|
||||||
...(groupedId && {
|
...(groupedId && {
|
||||||
groupedId,
|
groupedId,
|
||||||
@ -529,7 +529,7 @@ export function buildLocalForwardedMessage({
|
|||||||
content: updatedContent,
|
content: updatedContent,
|
||||||
date: scheduledAt || Math.round(Date.now() / 1000) + getServerTimeOffset(),
|
date: scheduledAt || Math.round(Date.now() / 1000) + getServerTimeOffset(),
|
||||||
isOutgoing: !asIncomingInChatWithSelf && toChat.type !== 'chatTypeChannel',
|
isOutgoing: !asIncomingInChatWithSelf && toChat.type !== 'chatTypeChannel',
|
||||||
senderId: sendAs?.id || currentUserId,
|
senderId: toChat.type !== 'chatTypePrivate' ? (sendAs?.id || currentUserId) : undefined,
|
||||||
sendingState: 'messageSendingStatePending',
|
sendingState: 'messageSendingStatePending',
|
||||||
groupedId,
|
groupedId,
|
||||||
isInAlbum,
|
isInAlbum,
|
||||||
|
|||||||
@ -171,7 +171,8 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
case 'newMessage': {
|
case 'newMessage': {
|
||||||
const { message } = update;
|
const { message } = update;
|
||||||
|
|
||||||
if (message.senderId === global.currentUserId && !message.isFromScheduled) {
|
const isOur = message.senderId ? message.senderId === global.currentUserId : message.isOutgoing;
|
||||||
|
if (isOur && !message.isFromScheduled) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,19 +13,18 @@ import {
|
|||||||
getMessageRecentReaction,
|
getMessageRecentReaction,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
getUserFullName,
|
getUserFullName,
|
||||||
isChatChannel,
|
|
||||||
} from '../global/helpers';
|
} from '../global/helpers';
|
||||||
import { getIsChatMuted, getIsChatSilent, getShouldShowMessagePreview } from '../global/helpers/notifications';
|
import { getIsChatMuted, getIsChatSilent, getShouldShowMessagePreview } from '../global/helpers/notifications';
|
||||||
import { getMessageSenderName } from '../global/helpers/peers';
|
import { getMessageSenderName } from '../global/helpers/peers';
|
||||||
import {
|
import {
|
||||||
selectChat,
|
|
||||||
selectCurrentMessageList,
|
selectCurrentMessageList,
|
||||||
selectIsChatWithSelf,
|
selectIsChatWithSelf,
|
||||||
selectNotifyDefaults,
|
selectNotifyDefaults,
|
||||||
selectNotifyException,
|
selectNotifyException,
|
||||||
|
selectPeer,
|
||||||
|
selectSender,
|
||||||
selectSettingsKeys,
|
selectSettingsKeys,
|
||||||
selectTopicFromMessage,
|
selectTopicFromMessage,
|
||||||
selectUser,
|
|
||||||
} from '../global/selectors';
|
} from '../global/selectors';
|
||||||
import { callApi } from '../api/gramjs';
|
import { callApi } from '../api/gramjs';
|
||||||
import { IS_ELECTRON, IS_SERVICE_WORKER_SUPPORTED, IS_TOUCH_ENV } from './browser/windowEnvironment';
|
import { IS_ELECTRON, IS_SERVICE_WORKER_SUPPORTED, IS_TOUCH_ENV } from './browser/windowEnvironment';
|
||||||
@ -298,15 +297,13 @@ function checkIfShouldNotify(chat: ApiChat, message: Partial<ApiMessage>) {
|
|||||||
|
|
||||||
function getNotificationContent(chat: ApiChat, message: ApiMessage, reaction?: ApiPeerReaction) {
|
function getNotificationContent(chat: ApiChat, message: ApiMessage, reaction?: ApiPeerReaction) {
|
||||||
const global = getGlobal();
|
const global = getGlobal();
|
||||||
let {
|
let sender = selectSender(global, message);
|
||||||
senderId,
|
|
||||||
} = message;
|
|
||||||
const hasReaction = Boolean(reaction);
|
const hasReaction = Boolean(reaction);
|
||||||
if (hasReaction) senderId = reaction.peerId;
|
if (hasReaction) {
|
||||||
|
sender = selectPeer(global, reaction.peerId);
|
||||||
|
}
|
||||||
|
|
||||||
const { isScreenLocked } = global.passcode;
|
const { isScreenLocked } = global.passcode;
|
||||||
const messageSenderChat = senderId ? selectChat(global, senderId) : undefined;
|
|
||||||
const messageSenderUser = senderId ? selectUser(global, senderId) : undefined;
|
|
||||||
const privateChatUserId = getPrivateChatUserId(chat);
|
const privateChatUserId = getPrivateChatUserId(chat);
|
||||||
const isSelf = privateChatUserId === global.currentUserId;
|
const isSelf = privateChatUserId === global.currentUserId;
|
||||||
|
|
||||||
@ -315,10 +312,6 @@ function getNotificationContent(chat: ApiChat, message: ApiMessage, reaction?: A
|
|||||||
!isScreenLocked
|
!isScreenLocked
|
||||||
&& getShouldShowMessagePreview(chat, selectNotifyDefaults(global), selectNotifyException(global, chat.id))
|
&& getShouldShowMessagePreview(chat, selectNotifyDefaults(global), selectNotifyException(global, chat.id))
|
||||||
) {
|
) {
|
||||||
const isChat = chat && (isChatChannel(chat) || message.senderId === message.chatId);
|
|
||||||
|
|
||||||
// TODO[forums] Support ApiChat
|
|
||||||
const sender = isChat ? messageSenderChat : messageSenderUser;
|
|
||||||
const senderName = sender ? getMessageSenderName(oldTranslate, chat.id, sender) : undefined;
|
const senderName = sender ? getMessageSenderName(oldTranslate, chat.id, sender) : undefined;
|
||||||
let summary = jsxToHtml(<span><MessageSummary message={message} /></span>)[0].textContent || '';
|
let summary = jsxToHtml(<span><MessageSummary message={message} /></span>)[0].textContent || '';
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user