This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/models/session.js

41 lines
908 B
JavaScript

/**
A data model representing current session data. You can put transient
data here you might want later.
@class Session
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
Discourse.Session = Discourse.Model.extend({
init: function() {
this.set('highestSeenByTopic', {});
}
});
Discourse.Session.reopenClass({
/**
Returns the current session.
@method current
@returns {Discourse.Session} the current session singleton
**/
current: function(property, value) {
if (!this.currentSession) {
this.currentSession = Discourse.Session.create();
}
// If we found the current session
if (property) {
if (value) {
this.currentSession.set(property, value);
} else {
return this.currentSession.get(property);
}
}
return property ? this.currentSession.get(property) : this.currentSession;
}
});