mirror of
https://github.com/flarum/core.git
synced 2025-07-17 06:41:21 +02:00
Rename discussion.readNumber
This commit is contained in:
@@ -24,7 +24,7 @@ Object.assign(Discussion.prototype, {
|
||||
mostRelevantPost: Model.hasOne('mostRelevantPost'),
|
||||
|
||||
lastReadAt: Model.attribute('lastReadAt', Model.transformDate),
|
||||
readNumber: Model.attribute('readNumber'),
|
||||
lastReadPostNumber: Model.attribute('lastReadPostNumber'),
|
||||
isUnread: computed('unreadCount', unreadCount => !!unreadCount),
|
||||
isRead: computed('unreadCount', unreadCount => app.session.user && !unreadCount),
|
||||
|
||||
@@ -68,7 +68,7 @@ Object.assign(Discussion.prototype, {
|
||||
const user = app.session.user;
|
||||
|
||||
if (user && user.readTime() < this.lastPostedAt()) {
|
||||
return Math.max(0, this.lastPostNumber() - (this.readNumber() || 0));
|
||||
return Math.max(0, this.lastPostNumber() - (this.lastReadPostNumber() || 0));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -75,7 +75,7 @@ export default class DiscussionListItem extends Component {
|
||||
const phrase = this.props.params.q;
|
||||
this.highlightRegExp = new RegExp(phrase+'|'+phrase.trim().replace(/\s+/g, '|'), 'gi');
|
||||
} else {
|
||||
jumpTo = Math.min(discussion.lastPostNumber(), (discussion.readNumber() || 0) + 1);
|
||||
jumpTo = Math.min(discussion.lastPostNumber(), (discussion.lastReadPostNumber() || 0) + 1);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -177,7 +177,7 @@ export default class DiscussionListItem extends Component {
|
||||
const discussion = this.props.discussion;
|
||||
|
||||
if (discussion.isUnread()) {
|
||||
discussion.save({readNumber: discussion.lastPostNumber()});
|
||||
discussion.save({lastReadPostNumber: discussion.lastPostNumber()});
|
||||
m.redraw();
|
||||
}
|
||||
}
|
||||
|
@@ -288,8 +288,8 @@ export default class DiscussionPage extends Page {
|
||||
|
||||
// If the user hasn't read past here before, then we'll update their read
|
||||
// state and redraw.
|
||||
if (app.session.user && endNumber > (discussion.readNumber() || 0)) {
|
||||
discussion.save({readNumber: endNumber});
|
||||
if (app.session.user && endNumber > (discussion.lastReadPostNumber() || 0)) {
|
||||
discussion.save({lastReadPostNumber: endNumber});
|
||||
m.redraw();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user