Fix own messages sometimes displayed as incoming (#2180)

This commit is contained in:
Alexander Zinchuk 2022-12-06 13:29:45 +01:00
parent a7ebcaf664
commit 7d37de7c6e
2 changed files with 7 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import type {
ApiMessage, ApiMessageExtendedMediaPreview, ApiUpdateConnectionStateType, OnApiUpdate,
} from '../types';
import { pick } from '../../util/iteratees';
import { omit, pick } from '../../util/iteratees';
import {
buildApiMessage,
buildApiMessageFromShort,
@ -298,7 +298,8 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
addMessageToLocalDb(update.message);
}
const message = buildApiMessage(update.message)!;
// Workaround for a weird server behavior when own message is marked as incoming
const message = omit(buildApiMessage(update.message)!, ['isOutgoing']);
onUpdate({
'@type': 'updateMessage',
@ -700,7 +701,9 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
if (originRequest instanceof GramJs.messages.ToggleNoForwards) {
shouldIgnoreNextChannelUpdate = true;
setTimeout(() => { shouldIgnoreNextChannelUpdate = false; }, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT);
setTimeout(() => {
shouldIgnoreNextChannelUpdate = false;
}, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT);
}
const chat = buildApiChatFromPreview(channel);

View File

@ -164,7 +164,6 @@ addActionHandler('apiUpdate', (global, actions, update) => {
const { chatId, id, message } = update;
const currentMessage = selectChatMessage(global, chatId, id);
const chat = selectChat(global, chatId);
global = updateWithLocalMedia(global, chatId, id, message);
@ -178,6 +177,7 @@ addActionHandler('apiUpdate', (global, actions, update) => {
message.threadInfo,
);
}
if (currentMessage) {
global = updateChatLastMessage(global, chatId, newMessage);
}