UX: When summarizing/filtering by participant jump to second post

This commit is contained in:
Robin Ward 2015-06-29 15:16:28 -04:00
parent b9add46c92
commit fb03c13bc6

View File

@ -16,6 +16,7 @@ function calcDayDiff(p1, p2) {
}
}
}
const PostStream = RestModel.extend({
loading: Em.computed.or('loadingAbove', 'loadingBelow', 'loadingFilter', 'stagingPost'),
notLoading: Em.computed.not('loading'),
@ -137,7 +138,13 @@ const PostStream = RestModel.extend({
toggleSummary() {
this.get('userFilters').clear();
this.toggleProperty('summary');
return this.refresh();
const self = this;
return this.refresh().then(function() {
if (self.get('summary')) {
self.jumpToSecondVisible();
}
});
},
toggleDeleted() {
@ -145,17 +152,33 @@ const PostStream = RestModel.extend({
return this.refresh();
},
jumpToSecondVisible() {
const posts = this.get('posts');
if (posts.length > 1) {
const secondPostNum = posts[1].get('post_number');
Discourse.URL.jumpToPost(secondPostNum);
}
},
// Filter the stream to a particular user.
toggleParticipant(username) {
const userFilters = this.get('userFilters');
this.set('summary', false);
this.set('show_deleted', true);
let jump = false;
if (userFilters.contains(username)) {
userFilters.removeObject(username);
} else {
userFilters.addObject(username);
jump = true;
}
return this.refresh();
const self = this;
return this.refresh().then(function() {
if (jump) {
self.jumpToSecondVisible();
}
});
},
/**