Some fixes

This commit is contained in:
Eduard Kuzmenko 2023-01-07 00:24:07 +04:00
parent 6dea8eca58
commit 43e3533db5
7 changed files with 65 additions and 10 deletions

View File

@ -4155,7 +4155,8 @@ export default class ChatBubbles {
if(wrapped?.onclick === 'im') { if(wrapped?.onclick === 'im') {
const map: {[type: string]: LangPackKey} = { const map: {[type: string]: LangPackKey} = {
telegram_channel: 'Chat.Message.ViewChannel', telegram_channel: 'Chat.Message.ViewChannel',
telegram_megagroup: 'OpenGroup' telegram_megagroup: 'OpenGroup',
telegram_bot: 'Chat.Message.ViewBot'
}; };
const langPackKey = map[webPage.type] || 'OpenMessage'; const langPackKey = map[webPage.type] || 'OpenMessage';

View File

@ -237,6 +237,8 @@ export default class ChatInput {
private sendAs: ChatSendAs; private sendAs: ChatSendAs;
public sendAsPeerId: PeerId; public sendAsPeerId: PeerId;
private replyInTopicOverlay: HTMLDivElement;
constructor( constructor(
private chat: Chat, private chat: Chat,
private appImManager: AppImManager, private appImManager: AppImManager,
@ -480,6 +482,10 @@ export default class ChatInput {
this.newMessageWrapper = document.createElement('div'); this.newMessageWrapper = document.createElement('div');
this.newMessageWrapper.classList.add('new-message-wrapper'); this.newMessageWrapper.classList.add('new-message-wrapper');
this.replyInTopicOverlay = document.createElement('div');
this.replyInTopicOverlay.classList.add('reply-in-topic-overlay', 'hide');
this.replyInTopicOverlay.append(i18n('Chat.Input.ReplyToAnswer'));
this.btnToggleEmoticons = ButtonIcon('none toggle-emoticons', {noRipple: true}); this.btnToggleEmoticons = ButtonIcon('none toggle-emoticons', {noRipple: true});
this.inputMessageContainer = document.createElement('div'); this.inputMessageContainer = document.createElement('div');
@ -983,7 +989,7 @@ export default class ChatInput {
}); });
}, {listenerSetter: this.listenerSetter}); }, {listenerSetter: this.listenerSetter});
this.controlContainer.append(this.botStartBtn); this.controlContainer.append(this.botStartBtn, this.replyInTopicOverlay);
// * pinned part start // * pinned part start
this.pinnedControlBtn = Button('btn-primary btn-transparent text-bold chat-input-control-button', {icon: 'unpin'}); this.pinnedControlBtn = Button('btn-primary btn-transparent text-bold chat-input-control-button', {icon: 'unpin'});
@ -1095,6 +1101,13 @@ export default class ChatInput {
this.center(true); this.center(true);
} }
public isReplyInTopicOverlayNeeded() {
return this.chat.isForum &&
!this.chat.isForumTopic &&
!this.replyToMsgId &&
this.chat.type === 'chat';
}
public async getNeededFakeContainer(startParam = this.startParam) { public async getNeededFakeContainer(startParam = this.startParam) {
if(this.chat.selection.isSelecting) { if(this.chat.selection.isSelecting) {
return this.fakeSelectionWrapper; return this.fakeSelectionWrapper;
@ -1102,7 +1115,8 @@ export default class ChatInput {
startParam !== undefined || startParam !== undefined ||
!(await this.chat.canSend()) || !(await this.chat.canSend()) ||
this.chat.type === 'pinned' || this.chat.type === 'pinned' ||
await this.chat.isStartButtonNeeded() await this.chat.isStartButtonNeeded() ||
this.isReplyInTopicOverlayNeeded()
) { ) {
return this.controlContainer; return this.controlContainer;
} }
@ -1442,12 +1456,21 @@ export default class ChatInput {
this.messageInput.dataset.peerId = '' + peerId; this.messageInput.dataset.peerId = '' + peerId;
} }
let haveSomethingInControl = false;
if(this.pinnedControlBtn) { if(this.pinnedControlBtn) {
this.pinnedControlBtn.classList.toggle('hide', this.chat.type !== 'pinned'); const good = this.chat.type === 'pinned';
haveSomethingInControl ||= good;
this.pinnedControlBtn.classList.toggle('hide', !good);
this.pinnedControlBtn.replaceChildren(i18n(canPinMessage ? 'Chat.Input.UnpinAll' : 'Chat.Pinned.DontShow')); this.pinnedControlBtn.replaceChildren(i18n(canPinMessage ? 'Chat.Input.UnpinAll' : 'Chat.Pinned.DontShow'));
} }
this.botStartBtn.classList.toggle('hide', this.chat.type === 'pinned'); {
const good = this.chat.isForum && !this.chat.isForumTopic && this.chat.type === 'chat';
haveSomethingInControl ||= good;
this.replyInTopicOverlay.classList.toggle('hide', !good);
}
this.botStartBtn.classList.toggle('hide', haveSomethingInControl);
// * testing // * testing
// this.startParam = this.appPeersManager.isBot(peerId) ? '123' : undefined; // this.startParam = this.appPeersManager.isBot(peerId) ? '123' : undefined;
@ -2945,11 +2968,16 @@ export default class ChatInput {
} }
this.setTopInfo('reply', f, peerTitleEl, message && (message as Message.message).message, undefined, message); this.setTopInfo('reply', f, peerTitleEl, message && (message as Message.message).message, undefined, message);
this.replyToMsgId = mid; this.setReplyToMsgId(mid)
}; };
f(); f();
} }
public setReplyToMsgId(mid: number) {
this.replyToMsgId = mid;
this.center(true);
}
public clearHelper(type?: ChatInputHelperType) { public clearHelper(type?: ChatInputHelperType) {
if(this.helperType === 'edit' && type !== 'edit') { if(this.helperType === 'edit' && type !== 'edit') {
this.clearInput(); this.clearInput();
@ -2962,7 +2990,7 @@ export default class ChatInput {
} }
if(type !== 'reply') { if(type !== 'reply') {
this.replyToMsgId = undefined; this.setReplyToMsgId(undefined);
this.forwarding = undefined; this.forwarding = undefined;
} }

View File

@ -21,7 +21,7 @@ const App = {
version: process.env.VERSION, version: process.env.VERSION,
versionFull: process.env.VERSION_FULL, versionFull: process.env.VERSION_FULL,
build: +process.env.BUILD, build: +process.env.BUILD,
langPackVersion: '0.7.1', langPackVersion: '0.7.2',
langPack: 'webk', langPack: 'webk',
langPackCode: 'en', langPackCode: 'en',
domains: MAIN_DOMAINS, domains: MAIN_DOMAINS,

View File

@ -929,6 +929,7 @@ const lang = {
'Chat.DropQuickDesc': 'in a quick way', 'Chat.DropQuickDesc': 'in a quick way',
'Chat.DropAsFilesDesc': 'without compression', 'Chat.DropAsFilesDesc': 'without compression',
'Chat.Edit.Cancel.Text': 'Are you sure you want to discard all changes?', 'Chat.Edit.Cancel.Text': 'Are you sure you want to discard all changes?',
'Chat.Input.ReplyToAnswer': 'Reply to message in topics',
'Chat.SendVoice.PrivacyError': '%@ doesn\'t accept voice and video messages', 'Chat.SendVoice.PrivacyError': '%@ doesn\'t accept voice and video messages',
'Chat.Service.Call.Cancelled': 'Cancelled', 'Chat.Service.Call.Cancelled': 'Cancelled',
'Chat.Service.Call.Missed': 'Missed', 'Chat.Service.Call.Missed': 'Missed',

View File

@ -1567,13 +1567,21 @@ export class AppMessagesManager extends AppManager {
} }
private generateReplyHeader(peerId: PeerId, replyToMsgId: number, replyToTopId?: number) { private generateReplyHeader(peerId: PeerId, replyToMsgId: number, replyToTopId?: number) {
const isForum = this.appPeersManager.isForum(peerId);
if(isForum && !replyToTopId) {
const originalMessage = this.getMessageByPeer(peerId, replyToMsgId);
if(originalMessage) {
replyToTopId = getMessageThreadId(originalMessage, true);
}
}
const header: MessageReplyHeader = { const header: MessageReplyHeader = {
_: 'messageReplyHeader', _: 'messageReplyHeader',
reply_to_msg_id: replyToMsgId || replyToTopId, reply_to_msg_id: replyToMsgId || replyToTopId,
pFlags: {} pFlags: {}
}; };
if(replyToTopId && this.appPeersManager.isForum(peerId) && GENERAL_TOPIC_ID !== replyToTopId) { if(replyToTopId && isForum && GENERAL_TOPIC_ID !== replyToTopId) {
header.pFlags.forum_topic = true; header.pFlags.forum_topic = true;
} }

View File

@ -8,5 +8,5 @@ import {User} from '../../../../layer';
import {REPLIES_PEER_ID} from '../../../mtproto/mtproto_config'; import {REPLIES_PEER_ID} from '../../../mtproto/mtproto_config';
export default function canSendToUser(user: User.user) { export default function canSendToUser(user: User.user) {
return !user.pFlags.deleted && user.id.toPeerId() !== REPLIES_PEER_ID; return !!(user && !user.pFlags.deleted && user.id.toPeerId() !== REPLIES_PEER_ID);
} }

View File

@ -521,6 +521,23 @@ $chat-input-border-radius: 1rem;
opacity: 1; opacity: 1;
} }
.reply-in-topic-overlay {
// position: absolute;
// top: 0;
// right: 0;
// bottom: 0;
// left: 0;
background-color: inherit;
border-radius: inherit;
z-index: 3;
display: flex;
align-items: center;
justify-content: center;
color: var(--secondary-text-color);
pointer-events: none;
padding: 0 1rem;
}
.bubbles.is-selecting:not(.backwards) ~ & { .bubbles.is-selecting:not(.backwards) ~ & {
.selection-wrapper { .selection-wrapper {
opacity: 1; opacity: 1;