REFACTOR: Remove container from `User` class
This commit is contained in:
parent
c94ba34882
commit
c068098f75
|
@ -30,6 +30,7 @@ import deprecated from "discourse-common/lib/deprecated";
|
||||||
import Site from "discourse/models/site";
|
import Site from "discourse/models/site";
|
||||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
import { escapeExpression } from "discourse/lib/utilities";
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
export const SECOND_FACTOR_METHODS = {
|
export const SECOND_FACTOR_METHODS = {
|
||||||
TOTP: 1,
|
TOTP: 1,
|
||||||
|
@ -794,8 +795,7 @@ const User = RestModel.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
summary() {
|
summary() {
|
||||||
// let { store } = this; would fail in tests
|
const store = getOwner(this).lookup("service:store");
|
||||||
const store = Discourse.__container__.lookup("service:store");
|
|
||||||
|
|
||||||
return ajax(userPath(`${this.username_lower}/summary.json`)).then(json => {
|
return ajax(userPath(`${this.username_lower}/summary.json`)).then(json => {
|
||||||
const summary = json.user_summary;
|
const summary = json.user_summary;
|
||||||
|
@ -977,7 +977,7 @@ User.reopenClass(Singleton, {
|
||||||
|
|
||||||
if (userJson) {
|
if (userJson) {
|
||||||
userJson = User.munge(userJson);
|
userJson = User.munge(userJson);
|
||||||
const store = Discourse.__container__.lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
return store.createRecord("user", userJson);
|
return store.createRecord("user", userJson);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue