Skip to content

Commit

Permalink
Reintroduce single attachment limit
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jan 4, 2019
1 parent 985b1d6 commit f9ea7be
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
5 changes: 5 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
15 changes: 15 additions & 0 deletions js/views/file_input_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -249,6 +252,12 @@
toast.render();
},

showMaxOneAttachmentError() {
const toast = new Whisper.MaxOneAttachmentToast();
toast.$el.insertAfter(this.$el);
toast.render();
},

// Housekeeping

addAttachment(attachment) {
Expand All @@ -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;
Expand Down
21 changes: 15 additions & 6 deletions ts/util/lint/exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit f9ea7be

Please sign in to comment.