mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
Moved highestSeenByTopic to the Discourse.Session
This commit is contained in:
@ -16,9 +16,6 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
|||||||
// Are we currently scrolling?
|
// Are we currently scrolling?
|
||||||
scrolling: false,
|
scrolling: false,
|
||||||
|
|
||||||
// The highest seen post number by topic
|
|
||||||
highestSeenByTopic: {},
|
|
||||||
|
|
||||||
// Helps with integration tests
|
// Helps with integration tests
|
||||||
URL_FIXTURES: {},
|
URL_FIXTURES: {},
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
|||||||
highestSeen = Math.max(highestSeen, parseInt(postNumber, 10));
|
highestSeen = Math.max(highestSeen, parseInt(postNumber, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
var highestSeenByTopic = Discourse.get('highestSeenByTopic');
|
var highestSeenByTopic = Discourse.Session.current('highestSeenByTopic');
|
||||||
if ((highestSeenByTopic[topicId] || 0) < highestSeen) {
|
if ((highestSeenByTopic[topicId] || 0) < highestSeen) {
|
||||||
highestSeenByTopic[topicId] = highestSeen;
|
highestSeenByTopic[topicId] = highestSeen;
|
||||||
Discourse.TopicTrackingState.current().updateSeen(topicId, highestSeen);
|
Discourse.TopicTrackingState.current().updateSeen(topicId, highestSeen);
|
||||||
|
@ -7,9 +7,14 @@
|
|||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.Session = Discourse.Model.extend({});
|
Discourse.Session = Discourse.Model.extend({
|
||||||
|
init: function() {
|
||||||
|
this.set('highestSeenByTopic', {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Discourse.Session.reopenClass({
|
Discourse.Session.reopenClass({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the current session.
|
Returns the current session.
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ Discourse.Topic = Discourse.Model.extend({
|
|||||||
// So take what the browser has seen into consideration.
|
// So take what the browser has seen into consideration.
|
||||||
displayNewPosts: function() {
|
displayNewPosts: function() {
|
||||||
var delta, highestSeen, result;
|
var delta, highestSeen, result;
|
||||||
if (highestSeen = Discourse.get('highestSeenByTopic')[this.get('id')]) {
|
if (highestSeen = Discourse.Session.current('highestSeenByTopic')[this.get('id')]) {
|
||||||
delta = highestSeen - this.get('last_read_post_number');
|
delta = highestSeen - this.get('last_read_post_number');
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
result = this.get('new_posts') - delta;
|
result = this.get('new_posts') - delta;
|
||||||
|
@ -14,3 +14,10 @@ test('current', function(){
|
|||||||
equal(session.get('orange'), "juice", "it can be updated");
|
equal(session.get('orange'), "juice", "it can be updated");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('highestSeenByTopic', function() {
|
||||||
|
|
||||||
|
var session = Discourse.Session.current();
|
||||||
|
deepEqual(session.get('highestSeenByTopic'), {}, "by default it returns an empty object");
|
||||||
|
|
||||||
|
});
|
Reference in New Issue
Block a user