pl-fe: admin dashboard support on non-pleroma backends

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2025-02-22 22:46:04 +01:00
parent 38304b0f52
commit 9abc3b9a67
6 changed files with 20 additions and 7 deletions

View File

@@ -33,7 +33,7 @@ const useAccount = (accountId?: string, opts: UseAccountOpts = {}) => {
{ enabled: !!accountId, transform: normalizeAccount },
);
const meta = useAppSelector((state) => accountId && state.accounts_meta[accountId]);
const meta = useAppSelector((state) => accountId ? state.accounts_meta[accountId] : undefined);
const {
relationship,
@@ -49,7 +49,14 @@ const useAccount = (accountId?: string, opts: UseAccountOpts = {}) => {
const isUnavailable = (me === entity?.id) ? false : (isBlocked && !features.blockersVisible);
const account = useMemo(
() => entity ? { ...entity, relationship, scrobble, __meta: { meta, ...entity.__meta } } : undefined,
() => entity ? {
...entity,
relationship,
scrobble,
__meta: { meta, ...entity.__meta },
// @ts-ignore
is_admin: meta?.role ? (meta.role.permissions & 0x1) === 0x1 : entity.is_admin,
} : undefined,
[entity, relationship, scrobble],
);