Fix dropped captions when the option is disabled

This commit is contained in:
morethanwords 2021-11-30 20:12:53 +04:00
parent 58dd3ac8b7
commit 99bf4ec3fb
2 changed files with 15 additions and 11 deletions

View File

@ -1981,7 +1981,7 @@ export default class ChatInput {
silent: sendSilent,
scheduleDate: scheduleDate,
dropAuthor: this.forwardElements.hideSender.checkboxField.checked,
dropCaptions: this.forwardElements.hideCaption.checkboxField.checked
dropCaptions: this.isDroppingCaptions()
});
}
@ -2035,6 +2035,10 @@ export default class ChatInput {
findUpTag(hideCaptionCheckboxField.label, 'FORM').classList.contains('hide');
}
private isDroppingCaptions() {
return !this.canToggleHideAuthor();
}
/* public sendSomething(callback: () => void, force = false) {
if(this.chat.type === 'scheduled' && !force) {
this.scheduleSending(() => this.sendSomething(callback, true));
@ -2099,6 +2103,15 @@ export default class ChatInput {
}
});
const form = findUpTag(this.forwardElements.showCaption.checkboxField.label, 'FORM');
form.classList.toggle('hide', !messagesWithCaptionsLength);
const hideCaption = this.forwardElements.hideCaption.checkboxField.checked;
if(messagesWithCaptionsLength && hideCaption) {
this.forwardElements.hideSender.checkboxField.setValueSilently(true);
} else if(this.forwardWasDroppingAuthor !== undefined) {
(this.forwardWasDroppingAuthor ? this.forwardElements.hideSender : this.forwardElements.showSender).checkboxField.setValueSilently(true);
}
const titleKey: LangPackKey = this.forwardElements.showSender.checkboxField.checked ? 'Chat.Accessory.Forward' : 'Chat.Accessory.Hidden';
const title = i18n(titleKey, [length]);
@ -2151,15 +2164,6 @@ export default class ChatInput {
intl.update();
});
const form = findUpTag(this.forwardElements.showCaption.checkboxField.label, 'FORM');
form.classList.toggle('hide', !messagesWithCaptionsLength);
const hideCaption = this.forwardElements.hideCaption.checkboxField.checked;
if(messagesWithCaptionsLength && hideCaption) {
this.forwardElements.hideSender.checkboxField.setValueSilently(true);
} else if(this.forwardWasDroppingAuthor !== undefined) {
(this.forwardWasDroppingAuthor ? this.forwardElements.hideSender : this.forwardElements.showSender).checkboxField.setValueSilently(true);
}
if(this.forwardHover) {
this.forwardHover.attachButtonListener(newReply, this.listenerSetter);
}

View File

@ -1924,7 +1924,7 @@ export class AppMessagesManager {
keys.push('views', 'forwards');
}
if(!options.dropCaptions) {
if(!options.dropCaptions || !originalMessage.media) {
keys.push('message');
}