Message List: Fix sent messages being marked as incoming
This commit is contained in:
parent
6ef383183f
commit
09dc41b650
@ -188,9 +188,6 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
case 'updateMessage': {
|
case 'updateMessage': {
|
||||||
const { chatId, id, message } = update;
|
const { chatId, id, message } = update;
|
||||||
|
|
||||||
const currentMessage = selectChatMessage(global, chatId, id);
|
|
||||||
const chat = selectChat(global, chatId);
|
|
||||||
|
|
||||||
global = updateWithLocalMedia(global, chatId, id, message);
|
global = updateWithLocalMedia(global, chatId, id, message);
|
||||||
|
|
||||||
const newMessage = selectChatMessage(global, chatId, id)!;
|
const newMessage = selectChatMessage(global, chatId, id)!;
|
||||||
@ -203,6 +200,9 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentMessage = selectChatMessage(global, chatId, id);
|
||||||
|
const chat = selectChat(global, chatId);
|
||||||
|
|
||||||
if (currentMessage) {
|
if (currentMessage) {
|
||||||
global = updateChatLastMessage(global, chatId, newMessage);
|
global = updateChatLastMessage(global, chatId, newMessage);
|
||||||
}
|
}
|
||||||
@ -672,31 +672,34 @@ function updateReactions<T extends GlobalState>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateWithLocalMedia(
|
function updateWithLocalMedia(
|
||||||
global: RequiredGlobalState, chatId: string, id: number, message: Partial<ApiMessage>, isScheduled = false,
|
global: RequiredGlobalState, chatId: string, id: number, messageUpdate: Partial<ApiMessage>, isScheduled = false,
|
||||||
) {
|
) {
|
||||||
// Preserve locally uploaded media.
|
|
||||||
const currentMessage = isScheduled
|
const currentMessage = isScheduled
|
||||||
? selectScheduledMessage(global, chatId, id)
|
? selectScheduledMessage(global, chatId, id)
|
||||||
: selectChatMessage(global, chatId, id);
|
: selectChatMessage(global, chatId, id);
|
||||||
if (currentMessage && message.content) {
|
|
||||||
|
// Preserve locally uploaded media.
|
||||||
|
if (currentMessage && messageUpdate.content) {
|
||||||
const {
|
const {
|
||||||
photo, video, sticker, document,
|
photo, video, sticker, document,
|
||||||
} = getMessageContent(currentMessage);
|
} = getMessageContent(currentMessage);
|
||||||
if (photo && message.content.photo) {
|
if (photo && messageUpdate.content.photo) {
|
||||||
message.content.photo.blobUrl = photo.blobUrl;
|
messageUpdate.content.photo.blobUrl = photo.blobUrl;
|
||||||
message.content.photo.thumbnail = photo.thumbnail;
|
messageUpdate.content.photo.thumbnail = photo.thumbnail;
|
||||||
} else if (video && message.content.video) {
|
} else if (video && messageUpdate.content.video) {
|
||||||
message.content.video.blobUrl = video.blobUrl;
|
messageUpdate.content.video.blobUrl = video.blobUrl;
|
||||||
} else if (sticker && message.content.sticker) {
|
} else if (sticker && messageUpdate.content.sticker) {
|
||||||
message.content.sticker.isPreloadedGlobally = sticker.isPreloadedGlobally;
|
messageUpdate.content.sticker.isPreloadedGlobally = sticker.isPreloadedGlobally;
|
||||||
} else if (document && message.content.document) {
|
} else if (document && messageUpdate.content.document) {
|
||||||
message.content.document.previewBlobUrl = document.previewBlobUrl;
|
messageUpdate.content.document.previewBlobUrl = document.previewBlobUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newMessage = currentMessage ? { ...currentMessage, ...messageUpdate } : messageUpdate;
|
||||||
|
|
||||||
return isScheduled
|
return isScheduled
|
||||||
? updateScheduledMessage(global, chatId, id, message)
|
? updateScheduledMessage(global, chatId, id, newMessage)
|
||||||
: updateChatMessage(global, chatId, id, message);
|
: updateChatMessage(global, chatId, id, newMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateThreadUnread<T extends GlobalState>(
|
function updateThreadUnread<T extends GlobalState>(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user