REFACTOR: Remove container from `User` class

This commit is contained in:
Robin Ward 2020-08-19 13:59:16 -04:00
parent c94ba34882
commit c068098f75
1 changed files with 3 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import deprecated from "discourse-common/lib/deprecated";
import Site from "discourse/models/site";
import { NotificationLevels } from "discourse/lib/notification-levels";
import { escapeExpression } from "discourse/lib/utilities";
import { getOwner } from "discourse-common/lib/get-owner";
export const SECOND_FACTOR_METHODS = {
TOTP: 1,
@ -794,8 +795,7 @@ const User = RestModel.extend({
},
summary() {
// let { store } = this; would fail in tests
const store = Discourse.__container__.lookup("service:store");
const store = getOwner(this).lookup("service:store");
return ajax(userPath(`${this.username_lower}/summary.json`)).then(json => {
const summary = json.user_summary;
@ -977,7 +977,7 @@ User.reopenClass(Singleton, {
if (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 null;