Support forwarding with replies

Fix resetting formatting on empty message input
Copy monospace text by click
Use different color for monospace in text
Replace sending messageEntityPre to messageEntityCode
Layer 140
This commit is contained in:
Eduard Kuzmenko 2022-04-16 19:21:50 +03:00
parent b6c51cdb39
commit f9e4c7ab16
16 changed files with 526 additions and 30 deletions

View File

@ -54,7 +54,7 @@ import serverTimeManager from "../../lib/mtproto/serverTimeManager";
import PeerTitle from "../peerTitle";
import findUpClassName from "../../helpers/dom/findUpClassName";
import findUpTag from "../../helpers/dom/findUpTag";
import { toast } from "../toast";
import { toast, toastNew } from "../toast";
import { getElementByPoint } from "../../helpers/dom/getElementByPoint";
import { getMiddleware } from "../../helpers/middleware";
import cancelEvent from "../../helpers/dom/cancelEvent";
@ -98,6 +98,10 @@ import findAndSplice from "../../helpers/array/findAndSplice";
import getViewportSlice from "../../helpers/dom/getViewportSlice";
import SuperIntersectionObserver from "../../helpers/dom/superIntersectionObserver";
import generateFakeIcon from "../generateFakeIcon";
import selectElementContents from "../../helpers/dom/selectElementContents";
import cancelSelection from "../../helpers/dom/cancelSelection";
import SelectionSaver from "../../helpers/selectionSaver";
import copyFromElement from "../../helpers/dom/copyFromElement";
const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
@ -632,6 +636,16 @@ export default class ChatBubbles {
attachClickEvent(this.scrollable.container, this.onBubblesClick, {listenerSetter: this.listenerSetter});
// this.listenerSetter.add(this.bubblesContainer)('click', this.onBubblesClick/* , {capture: true, passive: false} */);
this.listenerSetter.add(this.scrollable.container)('mousedown', (e) => {
const code: HTMLElement = findUpTag(e.target, 'CODE');
if(code) {
cancelEvent(e);
copyFromElement(code);
toastNew({langPackKey: 'TextCopied'});
return;
}
});
if(DEBUG) {
this.listenerSetter.add(this.bubblesContainer)('dblclick', (e) => {
const bubble = findUpClassName(e.target, 'grouped-item') || findUpClassName(e.target, 'bubble');

View File

@ -1711,14 +1711,16 @@ export default class ChatInput {
};
public applyMarkdown(type: MarkdownType, href?: string) {
const MONOSPACE_FONT = 'var(--font-monospace)';
const SPOILER_FONT = 'spoiler';
const commandsMap: Partial<{[key in typeof type]: string | (() => void)}> = {
bold: 'Bold',
italic: 'Italic',
underline: 'Underline',
strikethrough: 'Strikethrough',
monospace: () => document.execCommand('fontName', false, 'monospace'),
monospace: () => document.execCommand('fontName', false, MONOSPACE_FONT),
link: href ? () => document.execCommand('createLink', false, href) : () => document.execCommand('unlink', false, null),
spoiler: () => document.execCommand('fontName', false, 'spoiler')
spoiler: () => document.execCommand('fontName', false, SPOILER_FONT)
};
if(!commandsMap[type]) {
@ -1787,7 +1789,7 @@ export default class ChatInput {
//executed.push(document.execCommand('removeFormat', false, null));
if(haveThisType) {
executed.push(document.execCommand('fontName', false, 'Roboto'));
executed.push(this.resetCurrentFormatting());
} else {
executed.push(typeof(command) === 'function' ? command() : document.execCommand(command, false, null));
}
@ -1806,6 +1808,10 @@ export default class ChatInput {
return true;
}
private resetCurrentFormatting() {
return document.execCommand('fontName', false, 'Roboto');
}
private handleMarkdownShortcut = (e: KeyboardEvent) => {
// console.log('handleMarkdownShortcut', e);
const formatKeys: {[key: string]: MarkdownType} = {
@ -1956,6 +1962,14 @@ export default class ChatInput {
if(this.appImManager.markupTooltip) {
this.appImManager.markupTooltip.hide();
}
// * Chrome has a bug - it will preserve the formatting if the input with monospace text is cleared
// * so have to reset formatting
if(document.activeElement === this.messageInput) {
// document.execCommand('styleWithCSS', false, 'true');
this.resetCurrentFormatting();
// document.execCommand('styleWithCSS', false, 'false');
}
} else {
const time = Date.now();
if(time - this.lastTimeType >= 6000) {

View File

@ -0,0 +1,16 @@
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import SelectionSaver from "../selectionSaver";
import selectElementContents from "./selectElementContents";
export default function copyFromElement(element: HTMLElement) {
const saver = new SelectionSaver();
saver.save();
selectElementContents(element);
document.execCommand('copy');
saver.restore();
}

View File

@ -14,7 +14,7 @@ import { MessageEntity } from "../../layer";
export type MarkdownType = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'monospace' | 'link' | 'mentionName' | 'spoiler';
export type MarkdownTag = {
match: string,
entityName: Extract<MessageEntity['_'], 'messageEntityBold' | 'messageEntityUnderline' | 'messageEntityItalic' | 'messageEntityPre' | 'messageEntityStrike' | 'messageEntityTextUrl' | 'messageEntityMentionName' | 'messageEntitySpoiler'>;
entityName: Extract<MessageEntity['_'], 'messageEntityBold' | 'messageEntityUnderline' | 'messageEntityItalic' | 'messageEntityCode' | 'messageEntityStrike' | 'messageEntityTextUrl' | 'messageEntityMentionName' | 'messageEntitySpoiler'>;
};
// https://core.telegram.org/bots/api#html-style
@ -32,8 +32,8 @@ export const markdownTags: {[type in MarkdownType]: MarkdownTag} = {
entityName: 'messageEntityItalic'
},
monospace: {
match: '[style*="monospace"], [face="monospace"], pre',
entityName: 'messageEntityPre'
match: '[style*="monospace"], [face*="monospace"], pre',
entityName: 'messageEntityCode'
},
strikethrough: {
match: '[style*="line-through"], strike, del, s',
@ -135,7 +135,7 @@ export default function getRichElementValue(node: HTMLElement, lines: string[],
});
} else {
entities.push({
_: tag.entityName as any,
_: tag.entityName,
offset: offset.offset,
length: nodeValue.length
});

View File

@ -0,0 +1,40 @@
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import cancelSelection from "./dom/cancelSelection";
export default class SelectionSaver {
private input: HTMLElement;
private range: Range;
public save() {
const input = document.activeElement as HTMLElement;
if(input.isContentEditable || input.tagName === 'INPUT') {
this.input = input;
}
const selection = document.getSelection();
if(!selection.rangeCount || selection.isCollapsed) {
return;
}
this.range = selection.getRangeAt(0);
}
public restore() {
if(!this.range) {
cancelSelection();
return;
}
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(this.range);
if(this.input) {
this.input.focus();
}
}
}

View File

@ -692,6 +692,7 @@ const lang = {
"TelegramFeaturesUrl": "https://t.me/TelegramTips",
"ScamMessage": "SCAM",
"FakeMessage": "FAKE",
"TextCopied": "Text copied to clipboard",
// * macos
"AccountSettings.Filters": "Chat Folders",

397
src/layer.d.ts vendored
View File

@ -497,6 +497,7 @@ export namespace User {
scam?: true,
apply_min_photo?: true,
fake?: true,
bot_attach_menu?: true,
}>,
id: string | number,
access_hash?: string | number,
@ -586,7 +587,6 @@ export namespace Chat {
flags?: number,
pFlags?: Partial<{
creator?: true,
kicked?: true,
left?: true,
deactivated?: true,
call_active?: true,
@ -633,6 +633,8 @@ export namespace Chat {
fake?: true,
gigagroup?: true,
noforwards?: true,
join_to_send?: true,
join_request?: true,
}>,
id: string | number,
access_hash?: string | number,
@ -706,7 +708,9 @@ export namespace ChatFull {
has_scheduled?: true,
can_view_stats?: true,
blocked?: true,
can_delete_channel?: true,
}>,
flags2: number,
id: string | number,
about: string,
participants_count?: number,
@ -1034,7 +1038,7 @@ export namespace MessageMedia {
/**
* @link https://core.telegram.org/type/MessageAction
*/
export type MessageAction = MessageAction.messageActionEmpty | MessageAction.messageActionChatCreate | MessageAction.messageActionChatEditTitle | MessageAction.messageActionChatEditPhoto | MessageAction.messageActionChatDeletePhoto | MessageAction.messageActionChatAddUser | MessageAction.messageActionChatDeleteUser | MessageAction.messageActionChatJoinedByLink | MessageAction.messageActionChannelCreate | MessageAction.messageActionChatMigrateTo | MessageAction.messageActionChannelMigrateFrom | MessageAction.messageActionPinMessage | MessageAction.messageActionHistoryClear | MessageAction.messageActionGameScore | MessageAction.messageActionPaymentSentMe | MessageAction.messageActionPaymentSent | MessageAction.messageActionPhoneCall | MessageAction.messageActionScreenshotTaken | MessageAction.messageActionCustomAction | MessageAction.messageActionBotAllowed | MessageAction.messageActionSecureValuesSentMe | MessageAction.messageActionSecureValuesSent | MessageAction.messageActionContactSignUp | MessageAction.messageActionGeoProximityReached | MessageAction.messageActionGroupCall | MessageAction.messageActionInviteToGroupCall | MessageAction.messageActionSetMessagesTTL | MessageAction.messageActionGroupCallScheduled | MessageAction.messageActionSetChatTheme | MessageAction.messageActionChatJoinedByRequest | MessageAction.messageActionDiscussionStarted | MessageAction.messageActionChatLeave | MessageAction.messageActionChannelDeletePhoto | MessageAction.messageActionChannelEditTitle | MessageAction.messageActionChannelEditPhoto | MessageAction.messageActionChannelEditVideo | MessageAction.messageActionChatEditVideo | MessageAction.messageActionChatAddUsers | MessageAction.messageActionChatJoined | MessageAction.messageActionChatReturn | MessageAction.messageActionChatJoinedYou | MessageAction.messageActionChatReturnYou;
export type MessageAction = MessageAction.messageActionEmpty | MessageAction.messageActionChatCreate | MessageAction.messageActionChatEditTitle | MessageAction.messageActionChatEditPhoto | MessageAction.messageActionChatDeletePhoto | MessageAction.messageActionChatAddUser | MessageAction.messageActionChatDeleteUser | MessageAction.messageActionChatJoinedByLink | MessageAction.messageActionChannelCreate | MessageAction.messageActionChatMigrateTo | MessageAction.messageActionChannelMigrateFrom | MessageAction.messageActionPinMessage | MessageAction.messageActionHistoryClear | MessageAction.messageActionGameScore | MessageAction.messageActionPaymentSentMe | MessageAction.messageActionPaymentSent | MessageAction.messageActionPhoneCall | MessageAction.messageActionScreenshotTaken | MessageAction.messageActionCustomAction | MessageAction.messageActionBotAllowed | MessageAction.messageActionSecureValuesSentMe | MessageAction.messageActionSecureValuesSent | MessageAction.messageActionContactSignUp | MessageAction.messageActionGeoProximityReached | MessageAction.messageActionGroupCall | MessageAction.messageActionInviteToGroupCall | MessageAction.messageActionSetMessagesTTL | MessageAction.messageActionGroupCallScheduled | MessageAction.messageActionSetChatTheme | MessageAction.messageActionChatJoinedByRequest | MessageAction.messageActionWebViewDataSentMe | MessageAction.messageActionWebViewDataSent | MessageAction.messageActionDiscussionStarted | MessageAction.messageActionChatLeave | MessageAction.messageActionChannelDeletePhoto | MessageAction.messageActionChannelEditTitle | MessageAction.messageActionChannelEditPhoto | MessageAction.messageActionChannelEditVideo | MessageAction.messageActionChatEditVideo | MessageAction.messageActionChatAddUsers | MessageAction.messageActionChatJoined | MessageAction.messageActionChatReturn | MessageAction.messageActionChatJoinedYou | MessageAction.messageActionChatReturnYou;
export namespace MessageAction {
export type messageActionEmpty = {
@ -1203,6 +1207,17 @@ export namespace MessageAction {
_: 'messageActionChatJoinedByRequest'
};
export type messageActionWebViewDataSentMe = {
_: 'messageActionWebViewDataSentMe',
text: string,
data: string
};
export type messageActionWebViewDataSent = {
_: 'messageActionWebViewDataSent',
text: string
};
export type messageActionDiscussionStarted = {
_: 'messageActionDiscussionStarted'
};
@ -1508,7 +1523,7 @@ export namespace InputPeerNotifySettings {
show_previews?: boolean,
silent?: boolean,
mute_until?: number,
sound?: string
sound?: NotificationSound
};
}
@ -1524,7 +1539,9 @@ export namespace PeerNotifySettings {
show_previews?: boolean,
silent?: boolean,
mute_until?: number,
sound?: string
ios_sound?: NotificationSound,
android_sound?: NotificationSound,
other_sound?: NotificationSound
};
}
@ -1663,7 +1680,9 @@ export namespace UserFull {
folder_id?: number,
ttl_period?: number,
theme_emoticon?: string,
private_forward_name?: string
private_forward_name?: string,
bot_group_admin_rights?: ChatAdminRights,
bot_broadcast_admin_rights?: ChatAdminRights
};
}
@ -1965,7 +1984,7 @@ export namespace MessagesFilter {
/**
* @link https://core.telegram.org/type/Update
*/
export type Update = Update.updateNewMessage | Update.updateMessageID | Update.updateDeleteMessages | Update.updateUserTyping | Update.updateChatUserTyping | Update.updateChatParticipants | Update.updateUserStatus | Update.updateUserName | Update.updateUserPhoto | Update.updateNewEncryptedMessage | Update.updateEncryptedChatTyping | Update.updateEncryption | Update.updateEncryptedMessagesRead | Update.updateChatParticipantAdd | Update.updateChatParticipantDelete | Update.updateDcOptions | Update.updateNotifySettings | Update.updateServiceNotification | Update.updatePrivacy | Update.updateUserPhone | Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox | Update.updateWebPage | Update.updateReadMessagesContents | Update.updateChannelTooLong | Update.updateChannel | Update.updateNewChannelMessage | Update.updateReadChannelInbox | Update.updateDeleteChannelMessages | Update.updateChannelMessageViews | Update.updateChatParticipantAdmin | Update.updateNewStickerSet | Update.updateStickerSetsOrder | Update.updateStickerSets | Update.updateSavedGifs | Update.updateBotInlineQuery | Update.updateBotInlineSend | Update.updateEditChannelMessage | Update.updateBotCallbackQuery | Update.updateEditMessage | Update.updateInlineBotCallbackQuery | Update.updateReadChannelOutbox | Update.updateDraftMessage | Update.updateReadFeaturedStickers | Update.updateRecentStickers | Update.updateConfig | Update.updatePtsChanged | Update.updateChannelWebPage | Update.updateDialogPinned | Update.updatePinnedDialogs | Update.updateBotWebhookJSON | Update.updateBotWebhookJSONQuery | Update.updateBotShippingQuery | Update.updateBotPrecheckoutQuery | Update.updatePhoneCall | Update.updateLangPackTooLong | Update.updateLangPack | Update.updateFavedStickers | Update.updateChannelReadMessagesContents | Update.updateContactsReset | Update.updateChannelAvailableMessages | Update.updateDialogUnreadMark | Update.updateMessagePoll | Update.updateChatDefaultBannedRights | Update.updateFolderPeers | Update.updatePeerSettings | Update.updatePeerLocated | Update.updateNewScheduledMessage | Update.updateDeleteScheduledMessages | Update.updateTheme | Update.updateGeoLiveViewed | Update.updateLoginToken | Update.updateMessagePollVote | Update.updateDialogFilter | Update.updateDialogFilterOrder | Update.updateDialogFilters | Update.updatePhoneCallSignalingData | Update.updateChannelMessageForwards | Update.updateReadChannelDiscussionInbox | Update.updateReadChannelDiscussionOutbox | Update.updatePeerBlocked | Update.updateChannelUserTyping | Update.updatePinnedMessages | Update.updatePinnedChannelMessages | Update.updateChat | Update.updateGroupCallParticipants | Update.updateGroupCall | Update.updatePeerHistoryTTL | Update.updateChatParticipant | Update.updateChannelParticipant | Update.updateBotStopped | Update.updateGroupCallConnection | Update.updateBotCommands | Update.updatePendingJoinRequests | Update.updateBotChatInviteRequester | Update.updateMessageReactions | Update.updateNewDiscussionMessage | Update.updateDeleteDiscussionMessages | Update.updateChannelReload;
export type Update = Update.updateNewMessage | Update.updateMessageID | Update.updateDeleteMessages | Update.updateUserTyping | Update.updateChatUserTyping | Update.updateChatParticipants | Update.updateUserStatus | Update.updateUserName | Update.updateUserPhoto | Update.updateNewEncryptedMessage | Update.updateEncryptedChatTyping | Update.updateEncryption | Update.updateEncryptedMessagesRead | Update.updateChatParticipantAdd | Update.updateChatParticipantDelete | Update.updateDcOptions | Update.updateNotifySettings | Update.updateServiceNotification | Update.updatePrivacy | Update.updateUserPhone | Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox | Update.updateWebPage | Update.updateReadMessagesContents | Update.updateChannelTooLong | Update.updateChannel | Update.updateNewChannelMessage | Update.updateReadChannelInbox | Update.updateDeleteChannelMessages | Update.updateChannelMessageViews | Update.updateChatParticipantAdmin | Update.updateNewStickerSet | Update.updateStickerSetsOrder | Update.updateStickerSets | Update.updateSavedGifs | Update.updateBotInlineQuery | Update.updateBotInlineSend | Update.updateEditChannelMessage | Update.updateBotCallbackQuery | Update.updateEditMessage | Update.updateInlineBotCallbackQuery | Update.updateReadChannelOutbox | Update.updateDraftMessage | Update.updateReadFeaturedStickers | Update.updateRecentStickers | Update.updateConfig | Update.updatePtsChanged | Update.updateChannelWebPage | Update.updateDialogPinned | Update.updatePinnedDialogs | Update.updateBotWebhookJSON | Update.updateBotWebhookJSONQuery | Update.updateBotShippingQuery | Update.updateBotPrecheckoutQuery | Update.updatePhoneCall | Update.updateLangPackTooLong | Update.updateLangPack | Update.updateFavedStickers | Update.updateChannelReadMessagesContents | Update.updateContactsReset | Update.updateChannelAvailableMessages | Update.updateDialogUnreadMark | Update.updateMessagePoll | Update.updateChatDefaultBannedRights | Update.updateFolderPeers | Update.updatePeerSettings | Update.updatePeerLocated | Update.updateNewScheduledMessage | Update.updateDeleteScheduledMessages | Update.updateTheme | Update.updateGeoLiveViewed | Update.updateLoginToken | Update.updateMessagePollVote | Update.updateDialogFilter | Update.updateDialogFilterOrder | Update.updateDialogFilters | Update.updatePhoneCallSignalingData | Update.updateChannelMessageForwards | Update.updateReadChannelDiscussionInbox | Update.updateReadChannelDiscussionOutbox | Update.updatePeerBlocked | Update.updateChannelUserTyping | Update.updatePinnedMessages | Update.updatePinnedChannelMessages | Update.updateChat | Update.updateGroupCallParticipants | Update.updateGroupCall | Update.updatePeerHistoryTTL | Update.updateChatParticipant | Update.updateChannelParticipant | Update.updateBotStopped | Update.updateGroupCallConnection | Update.updateBotCommands | Update.updatePendingJoinRequests | Update.updateBotChatInviteRequester | Update.updateMessageReactions | Update.updateAttachMenuBots | Update.updateWebViewResultSent | Update.updateBotMenuButton | Update.updateSavedRingtones | Update.updateNewDiscussionMessage | Update.updateDeleteDiscussionMessages | Update.updateChannelReload;
export namespace Update {
export type updateNewMessage = {
@ -2654,6 +2673,25 @@ export namespace Update {
local?: boolean
};
export type updateAttachMenuBots = {
_: 'updateAttachMenuBots'
};
export type updateWebViewResultSent = {
_: 'updateWebViewResultSent',
query_id: string | number
};
export type updateBotMenuButton = {
_: 'updateBotMenuButton',
bot_id: string | number,
button: BotMenuButton
};
export type updateSavedRingtones = {
_: 'updateSavedRingtones'
};
export type updateNewDiscussionMessage = {
_: 'updateNewDiscussionMessage',
message?: Message
@ -4055,14 +4093,15 @@ export namespace BotInfo {
_: 'botInfo',
user_id: string | number,
description: string,
commands: Array<BotCommand>
commands: Array<BotCommand>,
menu_button: BotMenuButton
};
}
/**
* @link https://core.telegram.org/type/KeyboardButton
*/
export type KeyboardButton = KeyboardButton.keyboardButton | KeyboardButton.keyboardButtonUrl | KeyboardButton.keyboardButtonCallback | KeyboardButton.keyboardButtonRequestPhone | KeyboardButton.keyboardButtonRequestGeoLocation | KeyboardButton.keyboardButtonSwitchInline | KeyboardButton.keyboardButtonGame | KeyboardButton.keyboardButtonBuy | KeyboardButton.keyboardButtonUrlAuth | KeyboardButton.inputKeyboardButtonUrlAuth | KeyboardButton.keyboardButtonRequestPoll | KeyboardButton.inputKeyboardButtonUserProfile | KeyboardButton.keyboardButtonUserProfile;
export type KeyboardButton = KeyboardButton.keyboardButton | KeyboardButton.keyboardButtonUrl | KeyboardButton.keyboardButtonCallback | KeyboardButton.keyboardButtonRequestPhone | KeyboardButton.keyboardButtonRequestGeoLocation | KeyboardButton.keyboardButtonSwitchInline | KeyboardButton.keyboardButtonGame | KeyboardButton.keyboardButtonBuy | KeyboardButton.keyboardButtonUrlAuth | KeyboardButton.inputKeyboardButtonUrlAuth | KeyboardButton.keyboardButtonRequestPoll | KeyboardButton.inputKeyboardButtonUserProfile | KeyboardButton.keyboardButtonUserProfile | KeyboardButton.keyboardButtonWebView | KeyboardButton.keyboardButtonSimpleWebView;
export namespace KeyboardButton {
export type keyboardButton = {
@ -4155,6 +4194,18 @@ export namespace KeyboardButton {
text: string,
user_id: string | number
};
export type keyboardButtonWebView = {
_: 'keyboardButtonWebView',
text: string,
url: string
};
export type keyboardButtonSimpleWebView = {
_: 'keyboardButtonSimpleWebView',
text: string,
url: string
};
}
/**
@ -8661,6 +8712,9 @@ export namespace MessageReplyHeader {
export type messageReplyHeader = {
_: 'messageReplyHeader',
flags?: number,
pFlags?: Partial<{
reply_to_scheduled?: true,
}>,
reply_to_msg_id: number,
reply_to_peer_id?: Peer,
reply_to_top_id?: number
@ -9457,6 +9511,201 @@ export namespace PhoneGroupCallStreamRtmpUrl {
};
}
/**
* @link https://core.telegram.org/type/AttachMenuBotIconColor
*/
export type AttachMenuBotIconColor = AttachMenuBotIconColor.attachMenuBotIconColor;
export namespace AttachMenuBotIconColor {
export type attachMenuBotIconColor = {
_: 'attachMenuBotIconColor',
name: string,
color: number
};
}
/**
* @link https://core.telegram.org/type/AttachMenuBotIcon
*/
export type AttachMenuBotIcon = AttachMenuBotIcon.attachMenuBotIcon;
export namespace AttachMenuBotIcon {
export type attachMenuBotIcon = {
_: 'attachMenuBotIcon',
flags?: number,
name: string,
icon: Document,
colors?: Array<AttachMenuBotIconColor>
};
}
/**
* @link https://core.telegram.org/type/AttachMenuBot
*/
export type AttachMenuBot = AttachMenuBot.attachMenuBot;
export namespace AttachMenuBot {
export type attachMenuBot = {
_: 'attachMenuBot',
flags?: number,
pFlags?: Partial<{
inactive?: true,
}>,
bot_id: string | number,
short_name: string,
icons: Array<AttachMenuBotIcon>
};
}
/**
* @link https://core.telegram.org/type/AttachMenuBots
*/
export type AttachMenuBots = AttachMenuBots.attachMenuBotsNotModified | AttachMenuBots.attachMenuBots;
export namespace AttachMenuBots {
export type attachMenuBotsNotModified = {
_: 'attachMenuBotsNotModified'
};
export type attachMenuBots = {
_: 'attachMenuBots',
hash: string | number,
bots: Array<AttachMenuBot>,
users: Array<User>
};
}
/**
* @link https://core.telegram.org/type/AttachMenuBotsBot
*/
export type AttachMenuBotsBot = AttachMenuBotsBot.attachMenuBotsBot;
export namespace AttachMenuBotsBot {
export type attachMenuBotsBot = {
_: 'attachMenuBotsBot',
bot: AttachMenuBot,
users: Array<User>
};
}
/**
* @link https://core.telegram.org/type/WebViewResult
*/
export type WebViewResult = WebViewResult.webViewResultUrl;
export namespace WebViewResult {
export type webViewResultUrl = {
_: 'webViewResultUrl',
query_id: string | number,
url: string
};
}
/**
* @link https://core.telegram.org/type/SimpleWebViewResult
*/
export type SimpleWebViewResult = SimpleWebViewResult.simpleWebViewResultUrl;
export namespace SimpleWebViewResult {
export type simpleWebViewResultUrl = {
_: 'simpleWebViewResultUrl',
url: string
};
}
/**
* @link https://core.telegram.org/type/WebViewMessageSent
*/
export type WebViewMessageSent = WebViewMessageSent.webViewMessageSent;
export namespace WebViewMessageSent {
export type webViewMessageSent = {
_: 'webViewMessageSent',
flags?: number,
msg_id?: InputBotInlineMessageID
};
}
/**
* @link https://core.telegram.org/type/BotMenuButton
*/
export type BotMenuButton = BotMenuButton.botMenuButtonDefault | BotMenuButton.botMenuButtonCommands | BotMenuButton.botMenuButton;
export namespace BotMenuButton {
export type botMenuButtonDefault = {
_: 'botMenuButtonDefault'
};
export type botMenuButtonCommands = {
_: 'botMenuButtonCommands'
};
export type botMenuButton = {
_: 'botMenuButton',
text: string,
url: string
};
}
/**
* @link https://core.telegram.org/type/account.SavedRingtones
*/
export type AccountSavedRingtones = AccountSavedRingtones.accountSavedRingtonesNotModified | AccountSavedRingtones.accountSavedRingtones;
export namespace AccountSavedRingtones {
export type accountSavedRingtonesNotModified = {
_: 'account.savedRingtonesNotModified'
};
export type accountSavedRingtones = {
_: 'account.savedRingtones',
hash: string | number,
ringtones: Array<Document>
};
}
/**
* @link https://core.telegram.org/type/NotificationSound
*/
export type NotificationSound = NotificationSound.notificationSoundDefault | NotificationSound.notificationSoundNone | NotificationSound.notificationSoundLocal | NotificationSound.notificationSoundRingtone;
export namespace NotificationSound {
export type notificationSoundDefault = {
_: 'notificationSoundDefault'
};
export type notificationSoundNone = {
_: 'notificationSoundNone'
};
export type notificationSoundLocal = {
_: 'notificationSoundLocal',
title: string,
data: string
};
export type notificationSoundRingtone = {
_: 'notificationSoundRingtone',
id: string | number
};
}
/**
* @link https://core.telegram.org/type/account.SavedRingtone
*/
export type AccountSavedRingtone = AccountSavedRingtone.accountSavedRingtone | AccountSavedRingtone.accountSavedRingtoneConverted;
export namespace AccountSavedRingtone {
export type accountSavedRingtone = {
_: 'account.savedRingtone'
};
export type accountSavedRingtoneConverted = {
_: 'account.savedRingtoneConverted',
document: Document
};
}
export interface ConstructorDeclMap {
'error': Error.error,
'inputPeerEmpty': InputPeer.inputPeerEmpty,
@ -10412,6 +10661,34 @@ export interface ConstructorDeclMap {
'inputReportReasonIllegalDrugs': ReportReason.inputReportReasonIllegalDrugs,
'inputReportReasonPersonalDetails': ReportReason.inputReportReasonPersonalDetails,
'phone.groupCallStreamRtmpUrl': PhoneGroupCallStreamRtmpUrl.phoneGroupCallStreamRtmpUrl,
'attachMenuBotIconColor': AttachMenuBotIconColor.attachMenuBotIconColor,
'attachMenuBotIcon': AttachMenuBotIcon.attachMenuBotIcon,
'attachMenuBot': AttachMenuBot.attachMenuBot,
'attachMenuBotsNotModified': AttachMenuBots.attachMenuBotsNotModified,
'attachMenuBots': AttachMenuBots.attachMenuBots,
'attachMenuBotsBot': AttachMenuBotsBot.attachMenuBotsBot,
'updateAttachMenuBots': Update.updateAttachMenuBots,
'webViewResultUrl': WebViewResult.webViewResultUrl,
'simpleWebViewResultUrl': SimpleWebViewResult.simpleWebViewResultUrl,
'webViewMessageSent': WebViewMessageSent.webViewMessageSent,
'updateWebViewResultSent': Update.updateWebViewResultSent,
'keyboardButtonWebView': KeyboardButton.keyboardButtonWebView,
'keyboardButtonSimpleWebView': KeyboardButton.keyboardButtonSimpleWebView,
'messageActionWebViewDataSentMe': MessageAction.messageActionWebViewDataSentMe,
'messageActionWebViewDataSent': MessageAction.messageActionWebViewDataSent,
'updateBotMenuButton': Update.updateBotMenuButton,
'botMenuButtonDefault': BotMenuButton.botMenuButtonDefault,
'botMenuButtonCommands': BotMenuButton.botMenuButtonCommands,
'botMenuButton': BotMenuButton.botMenuButton,
'account.savedRingtonesNotModified': AccountSavedRingtones.accountSavedRingtonesNotModified,
'account.savedRingtones': AccountSavedRingtones.accountSavedRingtones,
'updateSavedRingtones': Update.updateSavedRingtones,
'notificationSoundDefault': NotificationSound.notificationSoundDefault,
'notificationSoundNone': NotificationSound.notificationSoundNone,
'notificationSoundLocal': NotificationSound.notificationSoundLocal,
'notificationSoundRingtone': NotificationSound.notificationSoundRingtone,
'account.savedRingtone': AccountSavedRingtone.accountSavedRingtone,
'account.savedRingtoneConverted': AccountSavedRingtone.accountSavedRingtoneConverted,
'messageEntityEmoji': MessageEntity.messageEntityEmoji,
'messageEntityHighlight': MessageEntity.messageEntityHighlight,
'messageEntityLinebreak': MessageEntity.messageEntityLinebreak,
@ -11760,6 +12037,8 @@ export type MessagesGetUnreadMentions = {
};
export type ChannelsDeleteHistory = {
flags?: number,
for_everyone?: boolean,
channel: InputChannel,
max_id: number
};
@ -12836,6 +13115,91 @@ export type MessagesSearchSentMedia = {
limit: number
};
export type MessagesGetAttachMenuBots = {
hash: string | number
};
export type MessagesGetAttachMenuBot = {
bot: InputUser
};
export type MessagesToggleBotInAttachMenu = {
bot: InputUser,
enabled: boolean
};
export type MessagesRequestWebView = {
flags?: number,
from_bot_menu?: boolean,
silent?: boolean,
peer: InputPeer,
bot: InputUser,
url?: string,
start_param?: string,
theme_params?: DataJSON,
reply_to_msg_id?: number
};
export type MessagesProlongWebView = {
flags?: number,
silent?: boolean,
peer: InputPeer,
bot: InputUser,
query_id: string | number,
reply_to_msg_id?: number
};
export type MessagesRequestSimpleWebView = {
flags?: number,
bot: InputUser,
url: string,
theme_params?: DataJSON
};
export type MessagesSendWebViewResultMessage = {
bot_query_id: string,
result: InputBotInlineResult
};
export type MessagesSendWebViewData = {
bot: InputUser,
random_id: string | number,
button_text: string,
data: string
};
export type BotsSetBotMenuButton = {
user_id: InputUser,
button: BotMenuButton
};
export type BotsGetBotMenuButton = {
user_id: InputUser
};
export type AccountGetSavedRingtones = {
hash: string | number
};
export type AccountSaveRingtone = {
id: InputDocument,
unsave: boolean
};
export type AccountUploadRingtone = {
file: InputFile,
file_name: string,
mime_type: string
};
export type BotsSetBotBroadcastDefaultAdminRights = {
admin_rights: ChatAdminRights
};
export type BotsSetBotGroupDefaultAdminRights = {
admin_rights: ChatAdminRights
};
export interface MethodDeclMap {
'invokeAfterMsg': {req: InvokeAfterMsg, res: any},
'invokeAfterMsgs': {req: InvokeAfterMsgs, res: any},
@ -13059,7 +13423,7 @@ export interface MethodDeclMap {
'channels.readMessageContents': {req: ChannelsReadMessageContents, res: boolean},
'contacts.resetSaved': {req: ContactsResetSaved, res: boolean},
'messages.getUnreadMentions': {req: MessagesGetUnreadMentions, res: MessagesMessages},
'channels.deleteHistory': {req: ChannelsDeleteHistory, res: boolean},
'channels.deleteHistory': {req: ChannelsDeleteHistory, res: Updates},
'help.getRecentMeUrls': {req: HelpGetRecentMeUrls, res: HelpRecentMeUrls},
'channels.togglePreHistoryHidden': {req: ChannelsTogglePreHistoryHidden, res: Updates},
'messages.readMentions': {req: MessagesReadMentions, res: MessagesAffectedHistory},
@ -13256,5 +13620,20 @@ export interface MethodDeclMap {
'phone.getGroupCallStreamChannels': {req: PhoneGetGroupCallStreamChannels, res: PhoneGroupCallStreamChannels},
'phone.getGroupCallStreamRtmpUrl': {req: PhoneGetGroupCallStreamRtmpUrl, res: PhoneGroupCallStreamRtmpUrl},
'messages.searchSentMedia': {req: MessagesSearchSentMedia, res: MessagesMessages},
'messages.getAttachMenuBots': {req: MessagesGetAttachMenuBots, res: AttachMenuBots},
'messages.getAttachMenuBot': {req: MessagesGetAttachMenuBot, res: AttachMenuBotsBot},
'messages.toggleBotInAttachMenu': {req: MessagesToggleBotInAttachMenu, res: boolean},
'messages.requestWebView': {req: MessagesRequestWebView, res: WebViewResult},
'messages.prolongWebView': {req: MessagesProlongWebView, res: boolean},
'messages.requestSimpleWebView': {req: MessagesRequestSimpleWebView, res: SimpleWebViewResult},
'messages.sendWebViewResultMessage': {req: MessagesSendWebViewResultMessage, res: WebViewMessageSent},
'messages.sendWebViewData': {req: MessagesSendWebViewData, res: Updates},
'bots.setBotMenuButton': {req: BotsSetBotMenuButton, res: boolean},
'bots.getBotMenuButton': {req: BotsGetBotMenuButton, res: BotMenuButton},
'account.getSavedRingtones': {req: AccountGetSavedRingtones, res: AccountSavedRingtones},
'account.saveRingtone': {req: AccountSaveRingtone, res: AccountSavedRingtone},
'account.uploadRingtone': {req: AccountUploadRingtone, res: Document},
'bots.setBotBroadcastDefaultAdminRights': {req: BotsSetBotBroadcastDefaultAdminRights, res: boolean},
'bots.setBotGroupDefaultAdminRights': {req: BotsSetBotGroupDefaultAdminRights, res: boolean},
}

View File

@ -238,7 +238,7 @@ export class AppChatsManager {
if(chat._ === 'chatForbidden' ||
chat._ === 'channelForbidden' ||
(chat as Chat.chat).pFlags.kicked ||
// (chat as Chat.chat).pFlags.kicked ||
(chat.pFlags.left && !(chat as Chat.channel).pFlags.megagroup)) {
return false;
}
@ -377,7 +377,7 @@ export class AppChatsManager {
|| chat._ === 'chatForbidden'
|| chat._ === 'chatEmpty'
|| (chat as Chat.chat).pFlags.left
|| (chat as Chat.chat).pFlags.kicked
// || (chat as Chat.chat).pFlags.kicked
|| (chat as Chat.chat).pFlags.deactivated) {
good = false;
}

View File

@ -178,7 +178,7 @@ export class AppMessagesManager {
[tempId: string]: {
[callbackName: string]: Partial<{
deferred: CancellablePromise<void>,
callback: (message: any) => Promise<any>
callback: (message: MyMessage) => Promise<any>
}>
}
} = {};
@ -414,7 +414,7 @@ export class AppMessagesManager {
return sendEntites;
}
public invokeAfterMessageIsSent(tempId: number, callbackName: string, callback: (message: any) => Promise<any>) {
public invokeAfterMessageIsSent(tempId: number, callbackName: string, callback: (message: MyMessage) => Promise<any>) {
const finalize = this.tempFinalizeCallbacks[tempId] ?? (this.tempFinalizeCallbacks[tempId] = {});
const obj = finalize[callbackName] ?? (finalize[callbackName] = {deferred: deferredPromise<void>()});
@ -2026,9 +2026,11 @@ export class AppMessagesManager {
}
} = {};
const newMessages = mids.map(mid => {
const newMids: number[] = [];
const newMessages = mids.map((mid) => {
const originalMessage: Message.message = this.getMessageByPeer(fromPeerId, mid);
const message: Message.message = this.generateOutgoingMessage(peerId, options);
newMids.push(message.id);
const keys: Array<keyof Message.message> = [
'entities',
@ -2049,6 +2051,20 @@ export class AppMessagesManager {
keys.push('message');
}
const replyToMid = originalMessage.reply_to?.reply_to_msg_id;
const replyToMessageIdx = mids.indexOf(replyToMid);
if(replyToMid && replyToMessageIdx !== -1) {
const newReplyToMid = newMids[replyToMessageIdx];
message.reply_to = {
_: 'messageReplyHeader',
reply_to_msg_id: newReplyToMid
};
/* this.invokeAfterMessageIsSent(newReplyToMid, 'reply', async(originalMessage) => {
message.reply_to.reply_to_msg_id = originalMessage.mid;
}); */
}
keys.forEach(key => {
// @ts-ignore
message[key] = originalMessage[key];
@ -6338,7 +6354,7 @@ export class AppMessagesManager {
}
public canForward(message: Message.message | Message.messageService) {
return !(message as Message.message).pFlags.noforwards && !appPeersManager.noForwards(message.peerId);
return message._ === 'message' && !(message as Message.message).pFlags.noforwards && !appPeersManager.noForwards(message.peerId);
}
private pushBatchUpdate<E extends keyof BatchUpdates, C extends BatchUpdates[E]>(

View File

@ -152,7 +152,7 @@ export default class VideoPlayer extends ControlsHover {
});
listenerSetter.add(document)('keydown', (e: KeyboardEvent) => {
if(rootScope.overlaysActive > 1) { // forward popup is active, etc
if(rootScope.overlaysActive > 1 || document.pictureInPictureElement) { // forward popup is active, etc
return;
}

File diff suppressed because one or more lines are too long

View File

@ -762,7 +762,12 @@ export default class DialogsStorage {
if(peerId.isAnyChat()) {
const chat: Chat = this.appChatsManager.getChat(peerId.toChatId());
// ! chatForbidden stays for chat where you're kicked
if(chat._ === 'channelForbidden' /* || chat._ === 'chatForbidden' */ || (chat as Chat.chat).pFlags.left || (chat as Chat.chat).pFlags.kicked) {
if(
chat._ === 'channelForbidden'
// || chat._ === 'chatForbidden'
|| (chat as Chat.chat).pFlags.left
// || (chat as Chat.chat).pFlags.kicked
) {
return;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1923,7 +1923,7 @@ $bubble-beside-button-width: 38px;
padding-top: 6px;
}
&:not(.sticker):not(.emoji-big) {
&:not(.sticker):not(.emoji-big):not(.forwarded) {
&.hide-name,
&:not(.is-group-first)/* , &.is-out */ {
.reply {
@ -2108,6 +2108,10 @@ $bubble-beside-button-width: 38px;
}
}
}
code {
cursor: pointer;
}
}
// * fix scroll with only 1 bubble
@ -2343,6 +2347,11 @@ $bubble-beside-button-width: 38px;
}
}
} */
pre,
code {
color: var(--monospace-text-color);
}
}
.bubble.is-out {

View File

@ -203,6 +203,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--poll-circle-color: var(--border-color);
--spoiler-background-color: #e3e5e8;
--spoiler-draft-background-color: #d9d9d9;
--monospace-text-color: var(--danger-color);
--message-background-color: var(--surface-color);
--message-checkbox-color: #61c642;
@ -275,6 +276,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--poll-circle-color: #fff;
--spoiler-background-color: #373e4e;
--spoiler-draft-background-color: #484848;
--monospace-text-color: var(--primary-text-color);
--message-background-color: var(--surface-color);
--message-checkbox-color: var(--primary-color);