FIX: Placeholders were missing when scrolling downwards

This commit is contained in:
Robin Ward 2016-02-09 13:45:59 -05:00
parent cd412976d7
commit bd967ba38c
6 changed files with 27 additions and 15 deletions

View File

@ -144,6 +144,8 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
if (lastLoadedPost && lastLoadedPost === post) {
postStream.appendMore().then(() => refresh());
// show loading stuff
refresh();
}
},

View File

@ -228,7 +228,7 @@ export default {
// TODO: Use ember closure actions
const result = topicController._actions[action].call(topicController, post);
if (result && result.then) {
this.appEvents.trigger('post-stream:refresh', selectedPostId)
this.appEvents.trigger('post-stream:refresh', selectedPostId);
}
}
}

View File

@ -1,13 +0,0 @@
<article class='placeholder'>
<div class='row'>
<div class="topic-avatar">
<div class='placeholder-avatar'></div>
</div>
<div class='topic-body'>
<div class='placeholder-text'></div>
<div class='placeholder-text'></div>
<div class='placeholder-text'></div>
</div>
</div>
</article>

View File

@ -1 +0,0 @@
export default Ember.View.extend({ templateName: 'post-placeholder' });

View File

@ -0,0 +1,17 @@
import { createWidget } from 'discourse/widgets/widget';
import { h } from 'virtual-dom';
export default createWidget('post-placeholder', {
tagName: 'article.placeholder',
html() {
return h('div.row', [
h('div.topic-avatar', h('div.placeholder-avatar')),
h('div.topic-body', [
h('div.placeholder-text'),
h('div.placeholder-text'),
h('div.placeholder-text')
])
]);
}
});

View File

@ -1,5 +1,6 @@
import { createWidget } from 'discourse/widgets/widget';
import transformPost from 'discourse/lib/transform-post';
import { Placeholder } from 'discourse/lib/posts-with-placeholders';
const DAY = 1000 * 60 * 60 * 24;
@ -21,6 +22,12 @@ export default createWidget('post-stream', {
for (let i=0; i<postArray.length; i++) {
const post = postArray[i];
if (post instanceof Placeholder) {
result.push(this.attach('post-placeholder'));
continue;
}
const nextPost = (i < postArray.length - 1) ? postArray[i+i] : null;
const transformed = transformPost(this.currentUser, this.site, post, prevPost, nextPost);