diff --git a/_locales/en/messages.json b/_locales/en/messages.json index edd6b109a5..dfef44aad1 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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.", diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index cf42da679c..4f5d4decf1 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -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; diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 299d96c974..8b299d0d42 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -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"