Fix own messages sometimes displayed as incoming (#2180)
This commit is contained in:
parent
a7ebcaf664
commit
7d37de7c6e
@ -4,7 +4,7 @@ import type {
|
|||||||
ApiMessage, ApiMessageExtendedMediaPreview, ApiUpdateConnectionStateType, OnApiUpdate,
|
ApiMessage, ApiMessageExtendedMediaPreview, ApiUpdateConnectionStateType, OnApiUpdate,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|
||||||
import { pick } from '../../util/iteratees';
|
import { omit, pick } from '../../util/iteratees';
|
||||||
import {
|
import {
|
||||||
buildApiMessage,
|
buildApiMessage,
|
||||||
buildApiMessageFromShort,
|
buildApiMessageFromShort,
|
||||||
@ -298,7 +298,8 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
|
|||||||
addMessageToLocalDb(update.message);
|
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({
|
onUpdate({
|
||||||
'@type': 'updateMessage',
|
'@type': 'updateMessage',
|
||||||
@ -700,7 +701,9 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
|
|||||||
|
|
||||||
if (originRequest instanceof GramJs.messages.ToggleNoForwards) {
|
if (originRequest instanceof GramJs.messages.ToggleNoForwards) {
|
||||||
shouldIgnoreNextChannelUpdate = true;
|
shouldIgnoreNextChannelUpdate = true;
|
||||||
setTimeout(() => { shouldIgnoreNextChannelUpdate = false; }, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT);
|
setTimeout(() => {
|
||||||
|
shouldIgnoreNextChannelUpdate = false;
|
||||||
|
}, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chat = buildApiChatFromPreview(channel);
|
const chat = buildApiChatFromPreview(channel);
|
||||||
|
|||||||
@ -164,7 +164,6 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
|||||||
const { chatId, id, message } = update;
|
const { chatId, id, message } = update;
|
||||||
|
|
||||||
const currentMessage = selectChatMessage(global, chatId, id);
|
const currentMessage = selectChatMessage(global, chatId, id);
|
||||||
|
|
||||||
const chat = selectChat(global, chatId);
|
const chat = selectChat(global, chatId);
|
||||||
|
|
||||||
global = updateWithLocalMedia(global, chatId, id, message);
|
global = updateWithLocalMedia(global, chatId, id, message);
|
||||||
@ -178,6 +177,7 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
|||||||
message.threadInfo,
|
message.threadInfo,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentMessage) {
|
if (currentMessage) {
|
||||||
global = updateChatLastMessage(global, chatId, newMessage);
|
global = updateChatLastMessage(global, chatId, newMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user