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

@ -551,6 +551,11 @@
"description":
"Shown in toast when user attempts to send .exe file, for example"
},
"maxOneAttachmentToast": {
"message": "The limit is one attachment per message.",
"description":
"An error popup when the user has attempted to add an attachment"
},
"oneNonImageAtATimeToast": {
"message":
"When including a non-image attachment, the limit is one attachment per message.",

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;

View file

@ -1226,7 +1226,7 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 216,
"lineNumber": 219,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"
@ -1235,7 +1235,7 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 222,
"lineNumber": 225,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"
@ -1244,7 +1244,7 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 230,
"lineNumber": 233,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"
@ -1253,7 +1253,7 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 236,
"lineNumber": 239,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"
@ -1262,7 +1262,7 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 242,
"lineNumber": 245,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"
@ -1271,7 +1271,16 @@
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 248,
"lineNumber": 251,
"reasonCategory": "usageTrusted",
"updated": "2019-01-04T20:24:04.674Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-insertAfter(",
"path": "js/views/file_input_view.js",
"line": " toast.$el.insertAfter(this.$el);",
"lineNumber": 257,
"reasonCategory": "usageTrusted",
"updated": "2018-12-15T03:04:48.403Z",
"reasonDetail": "Protected from arbitrary input"