Reintroduce single attachment limit

This commit is contained in:
Scott Nonnenberg 2019-01-04 12:18:46 -08:00
parent 985b1d6aa6
commit f9ea7be61f
3 changed files with 35 additions and 6 deletions

View file

@ -42,6 +42,9 @@
Whisper.MaxAttachmentsToast = Whisper.ToastView.extend({
template: i18n('maximumAttachments'),
});
Whisper.MaxOneAttachmentToast = Whisper.ToastView.extend({
template: i18n('maxOneAttachmentToast'),
});
Whisper.FileInputView = Backbone.View.extend({
tagName: 'span',
@ -249,6 +252,12 @@
toast.render();
},
showMaxOneAttachmentError() {
const toast = new Whisper.MaxOneAttachmentToast();
toast.$el.insertAfter(this.$el);
toast.render();
},
// Housekeeping
addAttachment(attachment) {
@ -268,6 +277,12 @@
const fileName = file.name;
const contentType = file.type;
// TODO: remove this when clients are ready to remove multiple image attachments
if (this.attachments.length > 0) {
this.showMaxOneAttachmentError();
return;
}
if (window.Signal.Util.isFileDangerous(fileName)) {
this.showDangerousError();
return;