Fix editing old messages in chats/channels

This commit is contained in:
morethanwords 2022-01-15 06:03:27 +04:00
parent 6c55fbb85d
commit 443822884d
2 changed files with 9 additions and 5 deletions

View File

@ -42,7 +42,7 @@ import LazyLoadQueue from "../lazyLoadQueue";
import ListenerSetter from "../../helpers/listenerSetter"; import ListenerSetter from "../../helpers/listenerSetter";
import PollElement from "../poll"; import PollElement from "../poll";
import AudioElement from "../audio"; import AudioElement from "../audio";
import { Message, MessageEntity, MessageMedia, MessageReplyHeader, Photo, PhotoSize, ReplyMarkup, Update, WebPage } from "../../layer"; import { Message, MessageEntity, MessageMedia, MessageReplyHeader, Photo, PhotoSize, ReplyMarkup, SponsoredMessage, Update, WebPage } from "../../layer";
import { NULL_PEER_ID, REPLIES_PEER_ID } from "../../lib/mtproto/mtproto_config"; import { NULL_PEER_ID, REPLIES_PEER_ID } from "../../lib/mtproto/mtproto_config";
import { FocusDirection } from "../../helpers/fastSmoothScroll"; import { FocusDirection } from "../../helpers/fastSmoothScroll";
import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent, interruptHeavyAnimation } from "../../hooks/useHeavyAnimationCheck"; import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent, interruptHeavyAnimation } from "../../hooks/useHeavyAnimationCheck";
@ -194,7 +194,7 @@ export default class ChatBubbles {
private getSponsoredMessagePromise: Promise<void>; private getSponsoredMessagePromise: Promise<void>;
private previousStickyDate: HTMLElement; private previousStickyDate: HTMLElement;
sponsoredMessage: import("/Users/kuzmenko/Documents/projects/tweb/src/layer").SponsoredMessage.sponsoredMessage; private sponsoredMessage: SponsoredMessage.sponsoredMessage;
constructor( constructor(
private chat: Chat, private chat: Chat,

View File

@ -3446,7 +3446,7 @@ export class AppMessagesManager {
return true; return true;
} }
public canEditMessage(message: any, kind: 'text' | 'poll' = 'text') { public canEditMessage(message: Message.message | Message.messageService, kind: 'text' | 'poll' = 'text') {
if(!message || !this.canMessageBeEdited(message, kind)) { if(!message || !this.canMessageBeEdited(message, kind)) {
return false; return false;
} }
@ -3456,8 +3456,12 @@ export class AppMessagesManager {
return true; return true;
} }
if((message.date < (tsNow(true) - rootScope.config.edit_time_limit) && if(!message.pFlags.out || (
message.media?._ !== 'messageMediaPoll') || !message.pFlags.out) { message.peerId.isUser() &&
message.date < (tsNow(true) - rootScope.config.edit_time_limit) &&
(message as Message.message).media?._ !== 'messageMediaPoll'
)
) {
return false; return false;
} }