FIX: First post wasn't rendering timeline

This commit is contained in:
Robin Ward 2016-05-20 12:30:33 -04:00
parent 4963d4d624
commit 6aef2b0a59
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D

View File

@ -82,8 +82,8 @@ createWidget('timeline-scrollarea', {
return { style: `height: ${SCROLLAREA_HEIGHT}px` };
},
defaultState() {
return { percentage: null, scrolledPost: 1 };
defaultState(attrs) {
return { percentage: this._percentFor(attrs.topic, attrs.topic.currentPost), scrolledPost: 1 };
},
position() {
@ -164,10 +164,13 @@ createWidget('timeline-scrollarea', {
topicCurrentPostChanged(postNumber) {
// If the post number didn't change keep our scroll position
if (postNumber !== this.state.scrolledPost) {
const total = this.attrs.topic.get('postStream.filteredPostsCount');
const perc = postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
this.state.percentage = perc;
this.state.percentage = this._percentFor(this.attrs.topic, postNumber);
}
},
_percentFor(topic, postNumber) {
const total = topic.get('postStream.filteredPostsCount');
return postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
}
});