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

View File

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

View File

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