movedTo(Uri), alsoKnownAsはユーザーidを返すように
This commit is contained in:
parent
eb4bca83fd
commit
3d88a91f61
7 changed files with 51 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div :class="$style.root">
|
||||
<div v-show="user" :class="$style.root">
|
||||
<i class="ti ti-plane-departure" style="margin-right: 8px;"></i>
|
||||
{{ i18n.ts.accountMoved }}
|
||||
<MkMention :class="$style.link" :username="username" :host="host ?? localHost"/>
|
||||
|
|
@ -10,11 +10,17 @@
|
|||
import MkMention from './MkMention.vue';
|
||||
import { i18n } from '@/i18n';
|
||||
import { host as localHost } from '@/config';
|
||||
import { ref } from 'vue';
|
||||
import { UserLite } from 'misskey-js/built/entities';
|
||||
import { api } from '@/os';
|
||||
|
||||
defineProps<{
|
||||
username: string;
|
||||
host: string;
|
||||
const user = ref<UserLite>();
|
||||
|
||||
const props = defineProps<{
|
||||
movedTo: string; // user id
|
||||
}>();
|
||||
|
||||
api('users/show', { userId: props.movedTo }).then(u => user.value = u);
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
|
|
|||
|
|
@ -51,20 +51,40 @@ import MkFolder from '@/components/MkFolder.vue';
|
|||
import * as os from '@/os';
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import { $i } from '@/account';
|
||||
import { toString } from 'misskey-js/built/acct';
|
||||
import { unisonReload } from '@/scripts/unison-reload';
|
||||
|
||||
const moveToAccount = ref('');
|
||||
const accountAliases = ref(['']);
|
||||
|
||||
async function init() {
|
||||
if ($i?.movedTo) {
|
||||
const movedTo = await os.api('users/show', { userId: $i.movedTo });
|
||||
moveToAccount.value = movedTo ? toString(movedTo) : '';
|
||||
} else {
|
||||
moveToAccount.value = '';
|
||||
}
|
||||
|
||||
if ($i?.alsoKnownAs && $i.alsoKnownAs.length > 0) {
|
||||
const alsoKnownAs = await os.api('users/show', { userIds: $i.alsoKnownAs });
|
||||
accountAliases.value = (alsoKnownAs && alsoKnownAs.length > 0) ? alsoKnownAs.map(user => `@${toString(user)}`) : [''];
|
||||
} else {
|
||||
accountAliases.value = [''];
|
||||
}
|
||||
}
|
||||
|
||||
async function move(): Promise<void> {
|
||||
const account = moveToAccount.value;
|
||||
const confirm = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.t('_accountMigration.migrationConfirm', { account: account.toString() }),
|
||||
text: i18n.t('_accountMigration.migrationConfirm', { account }),
|
||||
});
|
||||
if (confirm.canceled) return;
|
||||
os.apiWithDialog('i/move', {
|
||||
await os.apiWithDialog('i/move', {
|
||||
moveToAccount: account,
|
||||
});
|
||||
unisonReload();
|
||||
}
|
||||
|
||||
function add(): void {
|
||||
|
|
@ -73,12 +93,15 @@ function add(): void {
|
|||
|
||||
async function save(): Promise<void> {
|
||||
const alsoKnownAs = accountAliases.value.map(alias => alias.trim()).filter(alias => alias !== '');
|
||||
os.apiWithDialog('i/update', {
|
||||
const i = await os.apiWithDialog('i/update', {
|
||||
alsoKnownAs,
|
||||
});
|
||||
accountAliases.value = alsoKnownAs.length === 0 ? [''] : alsoKnownAs;
|
||||
$i.alsoKnownAs = i.alsoKnownAs;
|
||||
init();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
definePageMetadata({
|
||||
title: i18n.ts.accountMigration,
|
||||
icon: 'ti ti-plane',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<!-- <div class="punished" v-if="user.isSilenced"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSilenced }}</div> -->
|
||||
|
||||
<div class="profile _gaps">
|
||||
<MkAccountMoved v-if="user.movedToUri" :host="user.movedToUri.host" :username="user.movedToUri.username"/>
|
||||
<MkAccountMoved v-if="user.movedTo" :movedTo="user.movedTo" />
|
||||
<MkRemoteCaution v-if="user.host != null" :href="user.url ?? user.uri!" class="warn"/>
|
||||
|
||||
<div :key="user.id" class="main _panel">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue