UX: improve handling of hidden profiles (#54)

This commit is contained in:
Kris 2025-04-28 12:53:59 -04:00 committed by GitHub
parent d6bb016b17
commit eacda5d00e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import { action } from "@ember/object";
import UserCardContents from "discourse/components/user-card-contents";
import discourseComputed from "discourse/lib/decorators";
export default class UserCardStaticContents extends UserCardContents {
layoutName = "components/user-card-contents";
@ -13,6 +14,13 @@ export default class UserCardStaticContents extends UserCardContents {
willDestroyElement() {}
keyUp() {}
@discourseComputed("user.last_seen_at")
contentHidden(lastSeenAt) {
// we don't have the full user data available
// so if last_seen_at is missing, treat the profile as hidden
return !lastSeenAt;
}
// need to override this to work with the loading slider
@action
handleShowUser() {

View File

@ -90,17 +90,27 @@ export default {
// Each user card expects its own promise
// Rather than making a separate AJAX request for each
// We re-use the `user-cards.json` promise, and manipulate the data
const convertedPromise = promise.then((data) => {
promise.then((data) => {
// Find the correct user from users, and put it in the user attribute
const foundUser = data.users?.find(
(u) => u.id === uc.user.id
);
// cover disabled or inactive profiles
if (!foundUser) {
uc.set("loading", false);
return;
}
// Use Object.assign to avoid contaminating the source object
return Object.assign({}, data, {
user: data.users.find((u) => u.id === uc.user.id),
});
});
return uc.user
const convertedPromise = Promise.resolve(
Object.assign({}, data, { user: foundUser })
);
uc.user
.findDetails({ existingRequest: convertedPromise })
.finally(() => uc.set("loading", false));
});
});
}
return userCardInfos;