mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 17:53:23 +08:00
FIX: highest_post_number
was not being updated from gaps
This commit is contained in:
parent
80041b874c
commit
0e1d6272b9
|
@ -3,8 +3,8 @@ export default Ember.Component.extend({
|
|||
|
||||
initGaps: function(){
|
||||
this.set('loading', false);
|
||||
var before = this.get('before') === 'true',
|
||||
gaps = before ? this.get('postStream.gaps.before') : this.get('postStream.gaps.after');
|
||||
const before = this.get('before') === 'true';
|
||||
const gaps = before ? this.get('postStream.gaps.before') : this.get('postStream.gaps.after');
|
||||
|
||||
if (gaps) {
|
||||
this.set('gap', gaps[this.get('post.id')]);
|
||||
|
@ -16,29 +16,27 @@ export default Ember.Component.extend({
|
|||
this.rerender();
|
||||
}.observes('post.hasGap'),
|
||||
|
||||
render: function(buffer) {
|
||||
render(buffer) {
|
||||
if (this.get('loading')) {
|
||||
buffer.push(I18n.t('loading'));
|
||||
} else {
|
||||
var gapLength = this.get('gap.length');
|
||||
const gapLength = this.get('gap.length');
|
||||
if (gapLength) {
|
||||
buffer.push(I18n.t('post.gap', {count: gapLength}));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
click: function() {
|
||||
click() {
|
||||
if (this.get('loading') || (!this.get('gap'))) { return false; }
|
||||
this.set('loading', true);
|
||||
this.rerender();
|
||||
|
||||
var self = this,
|
||||
postStream = this.get('postStream'),
|
||||
filler = this.get('before') === 'true' ? postStream.fillGapBefore : postStream.fillGapAfter;
|
||||
const postStream = this.get('postStream');
|
||||
const filler = this.get('before') === 'true' ? postStream.fillGapBefore : postStream.fillGapAfter;
|
||||
|
||||
filler.call(postStream, this.get('post'), this.get('gap')).then(function() {
|
||||
// hide this control after the promise is resolved
|
||||
self.set('gap', null);
|
||||
filler.call(postStream, this.get('post'), this.get('gap')).then(() => {
|
||||
this.set('gap', null);
|
||||
});
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
||||
function entranceDate(dt, showTime) {
|
||||
var today = new Date();
|
||||
const today = new Date();
|
||||
|
||||
if (dt.toDateString() === today.toDateString()) {
|
||||
return moment(dt).format(I18n.t("dates.time"));
|
||||
|
@ -44,7 +44,7 @@ export default Ember.Controller.extend({
|
|||
}.property('bumpedDate'),
|
||||
|
||||
actions: {
|
||||
show: function(data) {
|
||||
show(data) {
|
||||
// Show the chooser but only if the model changes
|
||||
if (this.get('model') !== data.topic) {
|
||||
this.set('model', data.topic);
|
||||
|
@ -52,11 +52,11 @@ export default Ember.Controller.extend({
|
|||
}
|
||||
},
|
||||
|
||||
enterTop: function() {
|
||||
enterTop() {
|
||||
DiscourseURL.routeTo(this.get('model.url'));
|
||||
},
|
||||
|
||||
enterBottom: function() {
|
||||
enterBottom() {
|
||||
DiscourseURL.routeTo(this.get('model.lastPostUrl'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,14 +281,13 @@ const PostStream = RestModel.extend({
|
|||
// Fill in a gap of posts after a particular post
|
||||
fillGapAfter(post, gap) {
|
||||
const postId = post.get('id'),
|
||||
stream = this.get('stream'),
|
||||
idx = stream.indexOf(postId),
|
||||
self = this;
|
||||
stream = this.get('stream'),
|
||||
idx = stream.indexOf(postId);
|
||||
|
||||
if (idx !== -1) {
|
||||
stream.pushObjects(gap);
|
||||
return this.appendMore().then(function() {
|
||||
self.get('stream').enumerableContentDidChange();
|
||||
return this.appendMore().then(() => {
|
||||
this.get('stream').enumerableContentDidChange();
|
||||
});
|
||||
}
|
||||
return Ember.RSVP.resolve();
|
||||
|
@ -296,24 +295,18 @@ const PostStream = RestModel.extend({
|
|||
|
||||
// Appends the next window of posts to the stream. Call it when scrolling downwards.
|
||||
appendMore() {
|
||||
const self = this;
|
||||
|
||||
// Make sure we can append more posts
|
||||
if (!self.get('canAppendMore')) { return Ember.RSVP.resolve(); }
|
||||
if (!this.get('canAppendMore')) { return Ember.RSVP.resolve(); }
|
||||
|
||||
const postIds = self.get('nextWindow');
|
||||
const postIds = this.get('nextWindow');
|
||||
if (Ember.isEmpty(postIds)) { return Ember.RSVP.resolve(); }
|
||||
|
||||
self.set('loadingBelow', true);
|
||||
this.set('loadingBelow', true);
|
||||
|
||||
const stopLoading = function() {
|
||||
self.set('loadingBelow', false);
|
||||
};
|
||||
const stopLoading = () => this.set('loadingBelow', false);
|
||||
|
||||
return self.findPostsByIds(postIds).then(function(posts) {
|
||||
posts.forEach(function(p) {
|
||||
self.appendPost(p);
|
||||
});
|
||||
return this.findPostsByIds(postIds).then((posts) => {
|
||||
posts.forEach(p => this.appendPost(p));
|
||||
stopLoading();
|
||||
}, stopLoading);
|
||||
},
|
||||
|
@ -685,6 +678,12 @@ const PostStream = RestModel.extend({
|
|||
const postIdentityMap = this.get('postIdentityMap'),
|
||||
existing = postIdentityMap.get(post.get('id'));
|
||||
|
||||
// Update the `highest_post_number` if this post is higher.
|
||||
const postNumber = post.get('post_number');
|
||||
if (postNumber && postNumber > (this.get('topic.highest_post_number') || 0)) {
|
||||
this.set('topic.highest_post_number', postNumber);
|
||||
}
|
||||
|
||||
if (existing) {
|
||||
// If the post is in the identity map, update it and return the old reference.
|
||||
existing.updateFromPost(post);
|
||||
|
@ -693,12 +692,6 @@ const PostStream = RestModel.extend({
|
|||
|
||||
post.set('topic', this.get('topic'));
|
||||
postIdentityMap.set(post.get('id'), post);
|
||||
|
||||
// Update the `highest_post_number` if this post is higher.
|
||||
const postNumber = post.get('post_number');
|
||||
if (postNumber && postNumber > (this.get('topic.highest_post_number') || 0)) {
|
||||
this.set('topic.highest_post_number', postNumber);
|
||||
}
|
||||
}
|
||||
return post;
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a {{bind-attr href="topic.lastPostUrl"}}>
|
||||
<a href={{topic.lastPostUrl}}>
|
||||
<h4>{{i18n 'last_reply_lowercase'}}</h4>
|
||||
{{avatar details.last_poster imageSize="tiny"}}
|
||||
{{format-date topic.last_posted_at}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user