FIX: channel member status live updates (#25925)
This commit is contained in:
parent
8bec0ca083
commit
88f833418f
|
@ -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>
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue