Fix pinned action message not appearing (#2982)
This commit is contained in:
parent
e839c04f77
commit
a11ef0f618
@ -71,6 +71,7 @@ import { requestChatUpdate } from './chats';
|
|||||||
import { getEmojiOnlyCountForMessage } from '../../../global/helpers/getEmojiOnlyCountForMessage';
|
import { getEmojiOnlyCountForMessage } from '../../../global/helpers/getEmojiOnlyCountForMessage';
|
||||||
import { getServerTimeOffset } from '../../../util/serverTime';
|
import { getServerTimeOffset } from '../../../util/serverTime';
|
||||||
import { getApiChatIdFromMtpPeer } from '../apiBuilders/peers';
|
import { getApiChatIdFromMtpPeer } from '../apiBuilders/peers';
|
||||||
|
import { updater } from '../updater';
|
||||||
|
|
||||||
const FAST_SEND_TIMEOUT = 1000;
|
const FAST_SEND_TIMEOUT = 1000;
|
||||||
const INPUT_WAVEFORM_LENGTH = 63;
|
const INPUT_WAVEFORM_LENGTH = 63;
|
||||||
@ -665,13 +666,22 @@ async function uploadMedia(localMessage: ApiMessage, attachment: ApiAttachment,
|
|||||||
export async function pinMessage({
|
export async function pinMessage({
|
||||||
chat, messageId, isUnpin, isOneSide, isSilent,
|
chat, messageId, isUnpin, isOneSide, isSilent,
|
||||||
}: { chat: ApiChat; messageId: number; isUnpin: boolean; isOneSide?: boolean; isSilent?: boolean }) {
|
}: { chat: ApiChat; messageId: number; isUnpin: boolean; isOneSide?: boolean; isSilent?: boolean }) {
|
||||||
await invokeRequest(new GramJs.messages.UpdatePinnedMessage({
|
const result = await invokeRequest(new GramJs.messages.UpdatePinnedMessage({
|
||||||
peer: buildInputPeer(chat.id, chat.accessHash),
|
peer: buildInputPeer(chat.id, chat.accessHash),
|
||||||
id: messageId,
|
id: messageId,
|
||||||
...(isUnpin && { unpin: true }),
|
...(isUnpin && { unpin: true }),
|
||||||
...(isOneSide && { pmOneside: true }),
|
...(isOneSide && { pmOneside: true }),
|
||||||
...(isSilent && { silent: true }),
|
...(isSilent && { silent: true }),
|
||||||
}), true);
|
}), undefined, undefined, true);
|
||||||
|
|
||||||
|
if (!(result instanceof GramJs.Updates)) return;
|
||||||
|
|
||||||
|
// For some reason, Telegram returns UpdateMessageID when pinning a message with a randomId that is unknown to us,
|
||||||
|
// which causes an 'updateMessage' update instead of 'newMessage'. We ignore this update.
|
||||||
|
result.updates.forEach((update) => {
|
||||||
|
if (update instanceof GramJs.UpdateMessageID) return;
|
||||||
|
updater(update);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function unpinAllMessages({ chat, threadId }: { chat: ApiChat; threadId?: number }) {
|
export async function unpinAllMessages({ chat, threadId }: { chat: ApiChat; threadId?: number }) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user