From 616e1dcd16f669b2319a1b180688187ebe17c220 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 7 Apr 2017 14:37:05 -0400 Subject: [PATCH] FIX: Topic Timeline was impossible to close if you used the back button --- .../components/topic-navigation.js.es6 | 7 +++++- .../discourse/widgets/topic-timeline.js.es6 | 25 +++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-navigation.js.es6 b/app/assets/javascripts/discourse/components/topic-navigation.js.es6 index ecae615fc56..1f06f871629 100644 --- a/app/assets/javascripts/discourse/components/topic-navigation.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-navigation.js.es6 @@ -3,7 +3,12 @@ import showModal from 'discourse/lib/show-modal'; export default Ember.Component.extend({ composerOpen: null, - info: Em.Object.create(), + info: null, + + init() { + this._super(); + this.set('info', Ember.Object.create()); + }, _performCheckSize() { if (!this.element || this.isDestroying || this.isDestroyed) { return; } diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 6b927c05fcf..a77012282bc 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -154,8 +154,7 @@ createWidget('timeline-scrollarea', { if (this.state.position !== result.current) { this.state.position = result.current; - const timeline = this._findAncestorWithProperty('updatePosition'); - timeline.updatePosition.call(timeline, result.current); + this.sendWidgetAction('updatePosition', result.current); } return result; @@ -287,8 +286,6 @@ export default createWidget('topic-timeline', { this.state.position = pos; this.state.excerpt = ""; - this.scheduleRerender(); - const stream = this.attrs.topic.get('postStream'); // a little debounce to avoid flashing @@ -300,7 +297,6 @@ export default createWidget('topic-timeline', { // we have an off by one, stream is zero based, // pos is 1 based stream.excerpt(pos-1).then(info => { - if (info && this.state.position === pos) { let excerpt = ""; @@ -308,9 +304,7 @@ export default createWidget('topic-timeline', { excerpt = "" + info.username + ": "; } - excerpt += info.excerpt; - - this.state.excerpt = excerpt; + this.state.excerpt = excerpt + info.excerpt; this.scheduleRerender(); } }); @@ -332,16 +326,15 @@ export default createWidget('topic-timeline', { } let elems = [h('h2', this.attach('link', { - contents: ()=>titleHTML, - className: 'fancy-title', - action: 'jumpTop'}))]; - + contents: () => titleHTML, + className: 'fancy-title', + action: 'jumpTop' + }))]; if (this.state.excerpt) { - elems.push( - new RawHtml({ - html: "
" + this.state.excerpt + "
" - })); + elems.push(new RawHtml({ + html: "
" + this.state.excerpt + "
" + })); } result.push(h('div.title', elems));