mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
allow callers to pass in hint objects to admin-user and instance-info
This commit is contained in:
parent
645e27fc9e
commit
ffa0f06ea0
2 changed files with 33 additions and 15 deletions
|
@ -273,8 +273,14 @@ import SkBadgeStrip from '@/components/SkBadgeStrip.vue';
|
|||
const props = withDefaults(defineProps<{
|
||||
userId: string;
|
||||
initialTab?: string;
|
||||
userHint?: Misskey.entities.UserDetailed;
|
||||
infoHint?: Misskey.entities.AdminShowUserResponse;
|
||||
ipsHint?: Misskey.entities.AdminGetUserIpsResponse;
|
||||
}>(), {
|
||||
initialTab: 'overview',
|
||||
userHint: undefined,
|
||||
infoHint: undefined,
|
||||
ipsHint: undefined,
|
||||
});
|
||||
|
||||
const tab = ref(props.initialTab);
|
||||
|
@ -405,16 +411,23 @@ const announcementsPagination = {
|
|||
};
|
||||
const expandedRoles = ref([]);
|
||||
|
||||
function createFetcher() {
|
||||
return () => Promise.all([misskeyApi('users/show', {
|
||||
function createFetcher(withHint = true) {
|
||||
return () => Promise.all([
|
||||
(withHint && props.userHint) ? props.userHint : misskeyApi('users/show', {
|
||||
userId: props.userId,
|
||||
}), misskeyApi('admin/show-user', {
|
||||
}),
|
||||
(withHint && props.infoHint) ? props.infoHint : misskeyApi('admin/show-user', {
|
||||
userId: props.userId,
|
||||
}), iAmAdmin ? misskeyApi('admin/get-user-ips', {
|
||||
}),
|
||||
iAmAdmin
|
||||
? (withHint && props.ipsHint) ? props.ipsHint : misskeyApi('admin/get-user-ips', {
|
||||
userId: props.userId,
|
||||
}) : Promise.resolve(null), iAmAdmin ? misskeyApi('ap/get', {
|
||||
})
|
||||
: null,
|
||||
iAmAdmin ? misskeyApi('ap/get', {
|
||||
uri: `${url}/users/${props.userId}`,
|
||||
}).catch(() => null) : null]).then(([_user, _info, _ips, _ap]) => {
|
||||
}).catch(() => null) : null],
|
||||
).then(([_user, _info, _ips, _ap]) => {
|
||||
user.value = _user;
|
||||
info.value = _info;
|
||||
ips.value = _ips;
|
||||
|
@ -432,7 +445,7 @@ function createFetcher() {
|
|||
|
||||
async function refreshUser() {
|
||||
// Not a typo - createFetcher() returns a function()
|
||||
await createFetcher()();
|
||||
await createFetcher(false)();
|
||||
}
|
||||
|
||||
async function onMandatoryCWChanged(value: string) {
|
||||
|
|
|
@ -238,9 +238,14 @@ import SkBadgeStrip from '@/components/SkBadgeStrip.vue';
|
|||
|
||||
const $style = useCssModule();
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
host: string;
|
||||
}>();
|
||||
metaHint?: Misskey.entities.AdminMetaResponse;
|
||||
instanceHint?: Misskey.entities.FederationInstance;
|
||||
}>(), {
|
||||
metaHint: undefined,
|
||||
instanceHint: undefined,
|
||||
});
|
||||
|
||||
const tab = ref('overview');
|
||||
|
||||
|
@ -365,8 +370,8 @@ async function saveModerationNote() {
|
|||
|
||||
async function fetch(): Promise<void> {
|
||||
const [m, i] = await Promise.all([
|
||||
iAmAdmin ? misskeyApi('admin/meta') : null,
|
||||
misskeyApi('federation/show-instance', {
|
||||
props.metaHint ?? (iAmAdmin ? misskeyApi('admin/meta') : null),
|
||||
props.instanceHint ?? misskeyApi('federation/show-instance', {
|
||||
host: props.host,
|
||||
}),
|
||||
]);
|
||||
|
|
Loading…
Add table
Reference in a new issue