mirror of
https://github.com/discourse/discourse-user-card-directory.git
synced 2025-06-26 00:12:29 +00:00
UX: improve handling of hidden profiles (#54)
This commit is contained in:
parent
d6bb016b17
commit
eacda5d00e
@ -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() {
|
||||
|
@ -90,16 +90,26 @@ 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),
|
||||
});
|
||||
const convertedPromise = Promise.resolve(
|
||||
Object.assign({}, data, { user: foundUser })
|
||||
);
|
||||
uc.user
|
||||
.findDetails({ existingRequest: convertedPromise })
|
||||
.finally(() => uc.set("loading", false));
|
||||
});
|
||||
return uc.user
|
||||
.findDetails({ existingRequest: convertedPromise })
|
||||
.finally(() => uc.set("loading", false));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user