FEATURE: Reply Placeholders in Stream

This commit is contained in:
Robin Ward
2015-12-01 17:27:32 -05:00
parent 1987a35daf
commit 40c8d39137
14 changed files with 312 additions and 185 deletions
@@ -115,7 +115,7 @@ export default Ember.Controller.extend({
// If there is no current post, use the first post id from the stream
if (!postId && postStream) {
postId = postStream.get('firstPostId');
postId = postStream.get('stream.firstObject');
}
// If we're editing a post, fetch the reply when importing a quote
@@ -668,8 +668,8 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
topVisibleChanged(post) {
if (!post) { return; }
const postStream = this.get('model.postStream'),
firstLoadedPost = postStream.get('firstLoadedPost');
const postStream = this.get('model.postStream');
const firstLoadedPost = postStream.get('posts.firstObject');
this.set('model.currentPost', post.get('post_number'));
@@ -680,15 +680,16 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
// trigger a scroll after a promise resolves in a controller? We need
// to do this to preserve upwards infinte scrolling.
const $body = $('body');
let $elem = $('#post-cloak-' + post.get('post_number'));
const elemId = `#post_${post.get('post_number')}`;
const $elem = $(elemId).closest('.post-cloak');
const distToElement = $body.scrollTop() - $elem.position().top;
postStream.prependMore().then(function() {
Em.run.next(function () {
$elem = $('#post-cloak-' + post.get('post_number'));
const $refreshedElem = $(elemId).closest('.post-cloak');
// Quickly going back might mean the element is destroyed
const position = $elem.position();
const position = $refreshedElem.position();
if (position && position.top) {
$('html, body').scrollTop(position.top + distToElement);
}
@@ -706,8 +707,8 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
bottomVisibleChanged(post) {
if (!post) { return; }
const postStream = this.get('model.postStream'),
lastLoadedPost = postStream.get('lastLoadedPost');
const postStream = this.get('model.postStream');
const lastLoadedPost = postStream.get('posts.lastObject');
this.set('controllers.topic-progress.progressPosition', postStream.progressIndexOfPost(post));