From a6934a200efcc6d261454e545175e76ef0880ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 22 Sep 2015 17:45:55 +0200 Subject: [PATCH] FIX: don't use the filename for the upload placeholder --- app/assets/javascripts/discourse/lib/utilities.js | 4 ++-- app/assets/javascripts/discourse/views/composer.js.es6 | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/utilities.js b/app/assets/javascripts/discourse/lib/utilities.js index 672c752373d..f398e791033 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js +++ b/app/assets/javascripts/discourse/lib/utilities.js @@ -215,8 +215,8 @@ Discourse.Utilities = { } }, - getUploadPlaceholder: function(filename) { - return "[" + I18n.t("uploading_filename", { filename: filename }) + "]() "; + getUploadPlaceholder: function() { + return "[" + I18n.t("uploading") + "]() "; }, isAnImage: function(path) { diff --git a/app/assets/javascripts/discourse/views/composer.js.es6 b/app/assets/javascripts/discourse/views/composer.js.es6 index 71cbe5b32aa..c44edb49232 100644 --- a/app/assets/javascripts/discourse/views/composer.js.es6 +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -342,9 +342,9 @@ const ComposerView = Ember.View.extend(Ember.Evented, { this.messageBus.subscribe("/uploads/composer", upload => { if (!cancelledByTheUser) { if (upload && upload.url) { - const regex = new RegExp(`\\[${I18n.t("uploading")}.+?\\]\\(\\)`), + const old = Discourse.Utilities.getUploadPlaceholder(), markdown = Discourse.Utilities.getUploadMarkdown(upload); - this.replaceMarkdown(regex, markdown); + this.replaceMarkdown(old, markdown); } else { Discourse.Utilities.displayErrorForUpload(upload); } @@ -372,7 +372,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, { // deal with cancellation cancelledByTheUser = false; // add upload placeholder - const markdown = Discourse.Utilities.getUploadPlaceholder(data.files[0].name); + const markdown = Discourse.Utilities.getUploadPlaceholder(); this.addMarkdown(markdown); if (data["xhr"]) { @@ -527,9 +527,9 @@ const ComposerView = Ember.View.extend(Ember.Evented, { }); }, - replaceMarkdown(regex, text) { + replaceMarkdown(old, text) { const reply = this.get("model.reply"); - this.set("model.reply", reply.replace(regex, text)); + this.set("model.reply", reply.replace(old, text)); }, // Uses javascript to get the image sizes from the preview, if present