WIP - set Discourse.currentUser
This commit is contained in:
parent
38cc1962e7
commit
4843414de6
|
@ -8,7 +8,6 @@ import { computed } from "@ember/object";
|
|||
import FocusEvent from "discourse-common/mixins/focus-event";
|
||||
import EmberObject from "@ember/object";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
const _pluginCallbacks = [];
|
||||
|
||||
|
@ -63,7 +62,10 @@ const Discourse = Ember.Application.extend(FocusEvent, {
|
|||
}
|
||||
|
||||
var displayCount = this.displayCount;
|
||||
if (displayCount > 0 && !User.currentProp("dynamic_favicon")) {
|
||||
var dynamicFavicon = this.currentUser
|
||||
? !this.currentUser.get("dynamic_favicon")
|
||||
: false;
|
||||
if (displayCount > 0 && dynamicFavicon) {
|
||||
title = `(${displayCount}) ${title}`;
|
||||
}
|
||||
|
||||
|
@ -72,15 +74,15 @@ const Discourse = Ember.Application.extend(FocusEvent, {
|
|||
|
||||
@discourseComputed("contextCount", "notificationCount")
|
||||
displayCount() {
|
||||
return User.current() &&
|
||||
User.currentProp("title_count_mode") === "notifications"
|
||||
return this.currentUser &&
|
||||
this.currentUser.get("title_count_mode") === "notifications"
|
||||
? this.notificationCount
|
||||
: this.contextCount;
|
||||
},
|
||||
|
||||
@observes("contextCount", "notificationCount")
|
||||
faviconChanged() {
|
||||
if (User.currentProp("dynamic_favicon")) {
|
||||
if (this.currentUser && this.currentUser.get("dynamic_favicon")) {
|
||||
let url = Discourse.SiteSettings.site_favicon_url;
|
||||
|
||||
// Since the favicon is cached on the browser for a really long time, we
|
||||
|
|
|
@ -2,6 +2,7 @@ import Session from "discourse/models/session";
|
|||
import KeyValueStore from "discourse/lib/key-value-store";
|
||||
import Store from "discourse/models/store";
|
||||
import DiscourseLocation from "discourse/lib/discourse-location";
|
||||
import Discourse from "discourse";
|
||||
import SearchService from "discourse/services/search";
|
||||
import {
|
||||
startTracking,
|
||||
|
@ -33,6 +34,7 @@ export default {
|
|||
|
||||
const currentUser = User.current();
|
||||
app.register("current-user:main", currentUser, { instantiate: false });
|
||||
Discourse.currentUser = currentUser;
|
||||
|
||||
const topicTrackingState = TopicTrackingState.create({
|
||||
messageBus,
|
||||
|
|
|
@ -118,10 +118,12 @@ QUnit.testStart(function(ctx) {
|
|||
Discourse.BaseUri = "";
|
||||
Discourse.BaseUrl = "http://localhost:3000";
|
||||
|
||||
let User = require("discourse/models/user").default;
|
||||
let Session = require("discourse/models/session").default;
|
||||
Session.resetCurrent();
|
||||
Discourse.User.resetCurrent();
|
||||
User.resetCurrent();
|
||||
resetSite(Discourse.SiteSettings);
|
||||
Discourse.currentUser = User.current();
|
||||
|
||||
_DiscourseURL.redirectedTo = null;
|
||||
_DiscourseURL.redirectTo = function(url) {
|
||||
|
|
Loading…
Reference in New Issue