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
1 changed files with 8 additions and 5 deletions

View File

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