mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: channel member status live updates (#25925)
This commit is contained in:
@ -1,10 +1,19 @@
|
|||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
|
import { modifier } from "ember-modifier";
|
||||||
import UserStatusMessage from "discourse/components/user-status-message";
|
import UserStatusMessage from "discourse/components/user-status-message";
|
||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar";
|
import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar";
|
||||||
import ChatUserDisplayName from "discourse/plugins/chat/discourse/components/chat-user-display-name";
|
import ChatUserDisplayName from "discourse/plugins/chat/discourse/components/chat-user-display-name";
|
||||||
|
|
||||||
export default class ChatUserInfo extends Component {
|
export default class ChatUserInfo extends Component {
|
||||||
|
trackUserStatus = modifier((element, [user]) => {
|
||||||
|
user.statusManager.trackStatus();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
user.statusManager.stopTrackingStatus();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
get avatarSize() {
|
get avatarSize() {
|
||||||
return this.args.avatarSize ?? "medium";
|
return this.args.avatarSize ?? "medium";
|
||||||
}
|
}
|
||||||
@ -42,10 +51,12 @@ export default class ChatUserInfo extends Component {
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.showStatus}}
|
{{#if this.showStatus}}
|
||||||
<UserStatusMessage
|
<div class="user-status" {{this.trackUserStatus @user}}>
|
||||||
@status={{@user.status}}
|
<UserStatusMessage
|
||||||
@showDescription={{this.showStatusDescription}}
|
@status={{@user.status}}
|
||||||
/>
|
@showDescription={{this.showStatusDescription}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</template>
|
</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.username);
|
||||||
assert.dom().containsText(this.user.name);
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user