Browse Source

Fix dropped captions when the option is disabled

master
morethanwords 3 years ago
parent
commit
99bf4ec3fb
  1. 24
      src/components/chat/input.ts
  2. 2
      src/lib/appManagers/appMessagesManager.ts

24
src/components/chat/input.ts

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

2
src/lib/appManagers/appMessagesManager.ts

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

Loading…
Cancel
Save