1
0
Fork 0
forked from gitea/nas

Merge commit 'e3f0b955b8' into kbtopic-remove-quoteMerge

This commit is contained in:
KMY 2025-05-07 08:46:25 +09:00
commit 29b904483e
357 changed files with 1914 additions and 1355 deletions

View file

@ -11,27 +11,25 @@ interface Params {
id?: string;
}
export function useAccountId() {
export const useAccountId = () => {
const { acct, id } = useParams<Params>();
const dispatch = useAppDispatch();
const accountId = useAppSelector(
(state) =>
id ??
(state.accounts_map.get(normalizeForLookup(acct)) as string | undefined),
id ?? (acct ? state.accounts_map[normalizeForLookup(acct)] : undefined),
);
const account = useAppSelector((state) =>
accountId ? state.accounts.get(accountId) : undefined,
);
const isAccount = !!account;
const accountInStore = !!account;
const dispatch = useAppDispatch();
useEffect(() => {
if (!accountId) {
if (typeof accountId === 'undefined' && acct) {
dispatch(lookupAccount(acct));
} else if (!isAccount) {
} else if (accountId && !accountInStore) {
dispatch(fetchAccount(accountId));
}
}, [dispatch, accountId, acct, isAccount]);
}, [dispatch, accountId, acct, accountInStore]);
return accountId;
}
};

View file

@ -1,12 +1,14 @@
import { getAccountHidden } from 'mastodon/selectors/accounts';
import { useAppSelector } from 'mastodon/store';
export function useAccountVisibility(accountId?: string) {
const blockedBy = useAppSelector(
(state) => !!state.relationships.getIn([accountId, 'blocked_by'], false),
export function useAccountVisibility(accountId?: string | null) {
const blockedBy = useAppSelector((state) =>
accountId
? !!state.relationships.getIn([accountId, 'blocked_by'], false)
: false,
);
const suspended = useAppSelector(
(state) => !!state.accounts.getIn([accountId, 'suspended'], false),
const suspended = useAppSelector((state) =>
accountId ? !!state.accounts.getIn([accountId, 'suspended'], false) : false,
);
const hidden = useAppSelector((state) =>
accountId ? Boolean(getAccountHidden(state, accountId)) : false,