2015-03-06 12:37:24 -05:00
|
|
|
import Store from "discourse/models/store";
|
|
|
|
import RestAdapter from 'discourse/adapters/rest';
|
2015-09-03 16:55:55 -04:00
|
|
|
import KeyValueStore from 'discourse/lib/key-value-store';
|
|
|
|
import TopicTrackingState from 'discourse/models/topic-tracking-state';
|
2015-04-08 14:44:44 -04:00
|
|
|
import Resolver from 'discourse/ember/resolver';
|
2015-03-06 12:37:24 -05:00
|
|
|
|
|
|
|
export default function() {
|
2015-04-08 14:44:44 -04:00
|
|
|
const resolver = Resolver.create();
|
2015-03-06 12:37:24 -05:00
|
|
|
return Store.create({
|
|
|
|
container: {
|
|
|
|
lookup(type) {
|
|
|
|
if (type === "adapter:rest") {
|
2015-09-03 16:55:55 -04:00
|
|
|
this._restAdapter = this._restAdapter || RestAdapter.create({ container: this });
|
|
|
|
return (this._restAdapter);
|
|
|
|
}
|
|
|
|
if (type === "key-value-store:main") {
|
|
|
|
this._kvs = this._kvs || new KeyValueStore();
|
|
|
|
return (this._kvs);
|
|
|
|
}
|
|
|
|
if (type === "topic-tracking-state:main") {
|
2015-09-21 14:15:25 -04:00
|
|
|
this._tracker = this._tracker || TopicTrackingState.create();
|
2015-09-03 16:55:55 -04:00
|
|
|
return (this._tracker);
|
|
|
|
}
|
|
|
|
if (type === "site-settings:main") {
|
2016-06-14 14:31:51 -04:00
|
|
|
this._settings = this._settings || Discourse.SiteSettings;
|
2015-09-03 16:55:55 -04:00
|
|
|
return (this._settings);
|
2015-03-06 12:37:24 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-04-08 14:44:44 -04:00
|
|
|
lookupFactory(type) {
|
|
|
|
const split = type.split(':');
|
|
|
|
return resolver.customResolve({type: split[0], fullNameWithoutType: split[1]});
|
|
|
|
},
|
2015-03-06 12:37:24 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|