merge: upstream
This commit is contained in:
commit
11628e4b6a
285 changed files with 3413 additions and 1913 deletions
|
|
@ -16,7 +16,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #header>{{ i18n.ts.selectUser }}</template>
|
||||
<div>
|
||||
<div :class="$style.form">
|
||||
<FormSplit :minWidth="170">
|
||||
<MkInput v-if="localOnly" v-model="username" :autofocus="true" @update:modelValue="search">
|
||||
<template #label>{{ i18n.ts.username }}</template>
|
||||
<template #prefix>@</template>
|
||||
</MkInput>
|
||||
<FormSplit v-else :minWidth="170">
|
||||
<MkInput v-model="username" :autofocus="true" @update:modelValue="search">
|
||||
<template #label>{{ i18n.ts.username }}</template>
|
||||
<template #prefix>@</template>
|
||||
|
|
@ -66,7 +70,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
|
|||
import { defaultStore } from '@/store.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { hostname } from '@/config.js';
|
||||
import { host as currentHost, hostname } from '@/config.js';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'ok', selected: Misskey.entities.UserDetailed): void;
|
||||
|
|
@ -74,16 +78,19 @@ const emit = defineEmits<{
|
|||
(ev: 'closed'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
includeSelf?: boolean;
|
||||
local?: boolean;
|
||||
}>();
|
||||
localOnly?: boolean;
|
||||
}>(), {
|
||||
includeSelf: false,
|
||||
localOnly: false,
|
||||
});
|
||||
|
||||
const username = ref('');
|
||||
const host = ref('');
|
||||
const users = ref<Misskey.entities.UserDetailed[]>([]);
|
||||
const users = ref<Misskey.entities.UserLite[]>([]);
|
||||
const recentUsers = ref<Misskey.entities.UserDetailed[]>([]);
|
||||
const selected = ref<Misskey.entities.UserDetailed | null>(null);
|
||||
const selected = ref<Misskey.entities.UserLite | null>(null);
|
||||
const dialogEl = ref();
|
||||
|
||||
function search() {
|
||||
|
|
@ -91,25 +98,36 @@ function search() {
|
|||
users.value = [];
|
||||
return;
|
||||
}
|
||||
if (props.local) host.value = '.';
|
||||
|
||||
misskeyApi('users/search-by-username-and-host', {
|
||||
username: username.value,
|
||||
host: host.value,
|
||||
host: props.localOnly ? '.' : host.value,
|
||||
limit: 10,
|
||||
detail: false,
|
||||
}).then(_users => {
|
||||
users.value = _users;
|
||||
users.value = _users.filter((u) => {
|
||||
if (props.includeSelf) {
|
||||
return true;
|
||||
} else {
|
||||
return u.id !== $i?.id;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function ok() {
|
||||
async function ok() {
|
||||
if (selected.value == null) return;
|
||||
emit('ok', selected.value);
|
||||
|
||||
const user = await misskeyApi('users/show', {
|
||||
userId: selected.value.id,
|
||||
});
|
||||
emit('ok', user);
|
||||
|
||||
dialogEl.value.close();
|
||||
|
||||
// 最近使ったユーザー更新
|
||||
let recents = defaultStore.state.recentlyUsedUsers;
|
||||
recents = recents.filter(x => x !== selected.value.id);
|
||||
recents = recents.filter(x => x !== selected.value?.id);
|
||||
recents.unshift(selected.value.id);
|
||||
defaultStore.set('recentlyUsedUsers', recents.splice(0, 16));
|
||||
}
|
||||
|
|
@ -122,12 +140,23 @@ function cancel() {
|
|||
onMounted(() => {
|
||||
misskeyApi('users/show', {
|
||||
userIds: defaultStore.state.recentlyUsedUsers,
|
||||
}).then(users => {
|
||||
if (props.includeSelf && users.find(x => $i ? x.id === $i.id : true) == null) {
|
||||
recentUsers.value = [$i, ...users];
|
||||
} else {
|
||||
recentUsers.value = users;
|
||||
}
|
||||
}).then(foundUsers => {
|
||||
let _users = foundUsers;
|
||||
_users = _users.filter((u) => {
|
||||
if (props.localOnly) {
|
||||
return u.host == null;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
_users = _users.filter((u) => {
|
||||
if (props.includeSelf) {
|
||||
return true;
|
||||
} else {
|
||||
return u.id !== $i?.id;
|
||||
}
|
||||
});
|
||||
recentUsers.value = _users;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -135,7 +164,7 @@ onMounted(() => {
|
|||
<style lang="scss" module>
|
||||
|
||||
.form {
|
||||
padding: 0 var(--root-margin);
|
||||
padding: calc(var(--root-margin) / 2) var(--root-margin);
|
||||
}
|
||||
|
||||
.result,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue