DEV: attemps to limit Discourse.User.current() usage (#7943)
This commit is contained in:
parent
0603636cea
commit
fe7f0982af
|
@ -29,7 +29,7 @@ export default Ember.Controller.extend({
|
|||
I18n.t("yes_value"),
|
||||
confirmed => {
|
||||
if (confirmed) {
|
||||
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
||||
this.set("currentUser.hideReadOnlyAlert", true);
|
||||
this._toggleReadOnlyMode(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||
return this.model.resetBounceScore();
|
||||
},
|
||||
approve() {
|
||||
return this.model.approve();
|
||||
return this.model.approve(this.currentUser);
|
||||
},
|
||||
deactivate() {
|
||||
return this.model.deactivate();
|
||||
|
|
|
@ -227,14 +227,14 @@ const AdminUser = Discourse.User.extend({
|
|||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
approve() {
|
||||
approve(approvedBy) {
|
||||
return ajax(`/admin/users/${this.id}/approve`, {
|
||||
type: "PUT"
|
||||
}).then(() => {
|
||||
this.setProperties({
|
||||
can_approve: false,
|
||||
approved: true,
|
||||
approved_by: Discourse.User.current()
|
||||
approved_by: approvedBy
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ export default Discourse.Route.extend({
|
|||
},
|
||||
|
||||
sendInvites() {
|
||||
this.transitionTo("userInvited", Discourse.User.current());
|
||||
this.transitionTo("userInvited", this.currentUser);
|
||||
},
|
||||
|
||||
deleteUser(user) {
|
||||
|
|
|
@ -237,7 +237,7 @@ export default Ember.Component.extend({
|
|||
reason = I18n.t("composer.error.post_missing");
|
||||
} else if (missingReplyCharacters > 0) {
|
||||
reason = I18n.t("composer.error.post_length", { min: minimumPostLength });
|
||||
const tl = Discourse.User.currentProp("trust_level");
|
||||
const tl = this.get("currentUser.trust_level");
|
||||
if (tl === 0 || tl === 1) {
|
||||
reason +=
|
||||
"<br/>" +
|
||||
|
|
|
@ -29,7 +29,7 @@ export default Ember.Component.extend(
|
|||
|
||||
@computed("disableActions")
|
||||
canAct(disableActions) {
|
||||
return Discourse.User.current() && !disableActions;
|
||||
return this.currentUser && !disableActions;
|
||||
},
|
||||
|
||||
buildBuffer(buffer) {
|
||||
|
|
|
@ -17,7 +17,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
@computed
|
||||
loginRequired() {
|
||||
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||
return Discourse.SiteSettings.login_required && !this.currentUser;
|
||||
},
|
||||
|
||||
@computed
|
||||
|
|
|
@ -292,7 +292,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
@computed("model.creatingPrivateMessage", "model.targetUsernames")
|
||||
showWarning(creatingPrivateMessage, usernames) {
|
||||
if (!Discourse.User.currentProp("staff")) {
|
||||
if (!this.get("currentUser.staff")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,7 @@ export default DiscoveryController.extend({
|
|||
// this makes sure the composer isn't scoping to a specific category
|
||||
category: null,
|
||||
|
||||
@computed
|
||||
canEdit() {
|
||||
return Discourse.User.currentProp("staff");
|
||||
},
|
||||
canEdit: Ember.computed.reads("currentUser.staff"),
|
||||
|
||||
@computed("model.categories.[].featuredTopics.length")
|
||||
latestTopicOnly() {
|
||||
|
|
|
@ -42,15 +42,9 @@ export default Ember.Controller.extend({
|
|||
);
|
||||
},
|
||||
|
||||
@computed
|
||||
canInviteToForum() {
|
||||
return Discourse.User.currentProp("can_invite_to_forum");
|
||||
},
|
||||
canInviteToForum: Ember.computed.reads("currentUser.can_invite_to_forum"),
|
||||
|
||||
@computed
|
||||
canBulkInvite() {
|
||||
return Discourse.User.currentProp("admin");
|
||||
},
|
||||
canBulkInvite: Ember.computed.reads("currentUser.admin"),
|
||||
|
||||
showSearch: Ember.computed.gte("totalInvites", 10),
|
||||
|
||||
|
|
|
@ -16,12 +16,10 @@ export default Ember.Controller.extend({
|
|||
pmTaggingEnabled: Ember.computed.alias("site.can_tag_pms"),
|
||||
tagId: null,
|
||||
|
||||
@computed("user.viewingSelf")
|
||||
showNewPM(viewingSelf) {
|
||||
return (
|
||||
viewingSelf && Discourse.User.currentProp("can_send_private_messages")
|
||||
);
|
||||
},
|
||||
showNewPM: Ember.computed.and(
|
||||
"user.viewingSelf",
|
||||
"currentUser.can_send_private_messages"
|
||||
),
|
||||
|
||||
@computed("selected.[]", "bulkSelectEnabled")
|
||||
hasSelection(selected, bulkSelectEnabled) {
|
||||
|
|
|
@ -131,12 +131,7 @@ export default {
|
|||
|
||||
if (isPushNotificationsEnabled(user, site.mobileView)) {
|
||||
disableDesktopNotifications();
|
||||
registerPushNotifications(
|
||||
Discourse.User.current(),
|
||||
site.mobileView,
|
||||
router,
|
||||
appEvents
|
||||
);
|
||||
registerPushNotifications(user, site.mobileView, router, appEvents);
|
||||
} else {
|
||||
unsubscribePushNotifications(user);
|
||||
}
|
||||
|
|
|
@ -308,12 +308,6 @@ const Composer = RestModel.extend({
|
|||
return options;
|
||||
},
|
||||
|
||||
@computed
|
||||
isStaffUser() {
|
||||
const currentUser = Discourse.User.current();
|
||||
return currentUser && currentUser.staff;
|
||||
},
|
||||
|
||||
@computed(
|
||||
"loading",
|
||||
"canEditTitle",
|
||||
|
|
|
@ -191,10 +191,9 @@ export default DropdownSelectBoxComponent.extend({
|
|||
});
|
||||
}
|
||||
|
||||
const currentUser = Discourse.User.current();
|
||||
const showToggleTopicBump =
|
||||
currentUser &&
|
||||
(currentUser.get("staff") || currentUser.trust_level === 4);
|
||||
this.get("currentUser.staff") ||
|
||||
this.get("currentUser.trust_level") === 4;
|
||||
|
||||
if (action === REPLY && showToggleTopicBump) {
|
||||
items.push({
|
||||
|
|
Loading…
Reference in New Issue