From 2c384aec839c8dcddcbec87c404da4e25f7db352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 1 Oct 2015 21:43:43 +0200 Subject: [PATCH] FIX: reply as new topic wasn't working in FF when the post was only composed of an image --- .../javascripts/discourse/controllers/topic.js.es6 | 10 +++++----- app/assets/javascripts/discourse/lib/quote.js.es6 | 8 +++++--- app/assets/javascripts/discourse/models/post.js.es6 | 12 +++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 99edbfa2d16..70f3a967acb 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -410,12 +410,12 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { action: Discourse.Composer.CREATE_TOPIC, draftKey: Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY, categoryId: this.get('category.id') - }).then(function() { + }).then(() => { return Em.isEmpty(quotedText) ? Discourse.Post.loadQuote(post.get('id')) : quotedText; - }).then(function(q) { - const postUrl = "" + location.protocol + "//" + location.host + post.get('url'), - postLink = "[" + Handlebars.escapeExpression(self.get('model.title')) + "](" + postUrl + ")"; - composerController.appendText(I18n.t("post.continue_discussion", { postLink: postLink }) + "\n\n" + q); + }).then(q => { + const postUrl = `${location.protocol}//${location.host}${post.get('url')}`, + postLink = `[${Handlebars.escapeExpression(self.get('model.title'))}](${postUrl})`; + composerController.appendText(`${I18n.t("post.continue_discussion", { postLink })}\n\n${q}`); }); }, diff --git a/app/assets/javascripts/discourse/lib/quote.js.es6 b/app/assets/javascripts/discourse/lib/quote.js.es6 index d7c95bac494..bf1d290a5f0 100644 --- a/app/assets/javascripts/discourse/lib/quote.js.es6 +++ b/app/assets/javascripts/discourse/lib/quote.js.es6 @@ -3,15 +3,17 @@ export default { REGEXP: /\[quote=([^\]]*)\]((?:[\s\S](?!\[quote=[^\]]*\]))*?)\[\/quote\]/im, // Build the BBCode quote around the selected text - build: function(post, contents, opts) { + build(post, contents, opts) { var contents_hashed, result, sansQuotes, stripped, stripped_hashed, tmp; var full = opts && opts["full"]; var raw = opts && opts["raw"]; + if (!post) { return ""; } + if (!contents) contents = ""; sansQuotes = contents.replace(this.REGEXP, '').trim(); - if (sansQuotes.length === 0) return ""; + if (sansQuotes.length === 0) { return ""; } // Escape the content of the quote sansQuotes = sansQuotes.replace(/ Ember.Object.create(result)); }, hideRevision(postId, version) { @@ -419,16 +418,15 @@ Post.reopenClass({ }, loadQuote(postId) { - return Discourse.ajax("/posts/" + postId + ".json").then(function (result) { + return Discourse.ajax("/posts/" + postId + ".json").then(result => { const post = Discourse.Post.create(result); return Quote.build(post, post.get('raw'), {raw: true, full: true}); }); }, loadRawEmail(postId) { - return Discourse.ajax("/posts/" + postId + "/raw-email").then(function (result) { - return result.raw_email; - }); + return Discourse.ajax("/posts/" + postId + "/raw-email") + .then(result => result.raw_email); } });