more fixups

This commit is contained in:
Jarek Radosz 2025-05-28 14:50:04 +02:00
parent c1914aad11
commit d33b139a3d
No known key found for this signature in database
GPG Key ID: 98C198E7019429B3
3 changed files with 24 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import { getOwner } from "@ember/owner";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import ShowUserNotes from "../../components/show-user-notes";
import { showUserNotes } from "../../lib/user-notes";
@ -13,6 +13,8 @@ export default class AddUserNotesButton extends Component {
return siteSettings.user_notes_enabled && currentUser && currentUser.staff;
}
@service store;
init() {
super.init(...arguments);
const { model } = this;
@ -24,14 +26,15 @@ export default class AddUserNotesButton extends Component {
@action
showUserNotes() {
const store = getOwner(this).lookup("service:store");
const user = this.get("args.model");
showUserNotes(store, user.id, (count) => this.set("userNotesCount", count));
const user = this.model;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
<ShowUserNotes
@show={{action "showUserNotes"}}
@show={{this.showUserNotes}}
@count={{this.userNotesCount}}
/>
</template>

View File

@ -1,6 +1,6 @@
import Component from "@ember/component";
import EmberObject, { action } from "@ember/object";
import { getOwner } from "@ember/owner";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import DButton from "discourse/components/d-button";
import icon from "discourse/helpers/d-icon";
@ -15,6 +15,8 @@ export default class ShowUserNotesOnFlags extends Component {
return context.siteSettings.user_notes_enabled && args.user;
}
@service store;
init() {
super.init(...arguments);
const model = EmberObject.create(this.user);
@ -31,16 +33,17 @@ export default class ShowUserNotesOnFlags extends Component {
@action
showUserNotes() {
const store = getOwner(this).lookup("service:store");
const user = this.get("args.user");
showUserNotes(store, user.id, (count) => this.set("userNotesCount", count));
const user = this.user;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
{{#if this.userNotesCount}}
<DButton
@translatedTitle={{this.userNotesTitle}}
@action={{action "showUserNotes"}}
@action={{this.showUserNotes}}
class="btn btn-flat"
>
{{#if this.emojiEnabled}}

View File

@ -1,6 +1,6 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import { getOwner } from "@ember/owner";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import ShowUserNotes from "../../components/show-user-notes";
import { showUserNotes } from "../../lib/user-notes";
@ -13,6 +13,8 @@ export default class ShowNotesOnProfile extends Component {
return siteSettings.user_notes_enabled && currentUser && currentUser.staff;
}
@service store;
init() {
super.init(...arguments);
const { model } = this;
@ -24,14 +26,15 @@ export default class ShowNotesOnProfile extends Component {
@action
showUserNotes() {
const store = getOwner(this).lookup("service:store");
const user = this.get("args.model");
showUserNotes(store, user.id, (count) => this.set("userNotesCount", count));
const user = this.model;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
<ShowUserNotes
@show={{action "showUserNotes"}}
@show={{this.showUserNotes}}
@count={{this.userNotesCount}}
/>
</template>