FIX: channel member status live updates (#25925)

This commit is contained in:
David Battersby 2024-02-29 17:49:18 +08:00 committed by GitHub
parent 8bec0ca083
commit 88f833418f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 4 deletions

View File

@ -1,10 +1,19 @@
import Component from "@glimmer/component";
import { modifier } from "ember-modifier";
import UserStatusMessage from "discourse/components/user-status-message";
import { userPath } from "discourse/lib/url";
import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar";
import ChatUserDisplayName from "discourse/plugins/chat/discourse/components/chat-user-display-name";
export default class ChatUserInfo extends Component {
trackUserStatus = modifier((element, [user]) => {
user.statusManager.trackStatus();
return () => {
user.statusManager.stopTrackingStatus();
};
});
get avatarSize() {
return this.args.avatarSize ?? "medium";
}
@ -42,10 +51,12 @@ export default class ChatUserInfo extends Component {
{{/if}}
{{#if this.showStatus}}
<UserStatusMessage
@status={{@user.status}}
@showDescription={{this.showStatusDescription}}
/>
<div class="user-status" {{this.trackUserStatus @user}}>
<UserStatusMessage
@status={{@user.status}}
@showDescription={{this.showStatusDescription}}
/>
</div>
{{/if}}
{{/if}}
</template>

View File

@ -14,4 +14,21 @@ module("Discourse Chat | Component | chat-user-info", function (hooks) {
assert.dom().containsText(this.user.username);
assert.dom().containsText(this.user.name);
});
test("status message", async function (assert) {
this.siteSettings.enable_user_status = true;
this.set("user", this.currentUser);
this.user.setProperties({
status: { description: "happy", emoji: "smile" },
});
await render(
hbs`<ChatUserInfo @user={{this.user}} @showStatus={{true}} @showStatusDescription={{true}} />`
);
assert.dom("img.emoji[alt='smile']").exists("it shows the emoji");
assert.dom().containsText("happy");
});
});