2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
|
|
|
<div class="mk-follow-page">
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
2022-06-20 10:38:49 +02:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { mainRouter } from '@/router';
|
2022-09-01 17:22:31 +02:00
|
|
|
import { i18n } from '@/i18n';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
async function follow(user): Promise<void> {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
text: i18n.t('followConfirm', { name: user.name || user.username }),
|
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
if (canceled) {
|
|
|
|
window.close();
|
|
|
|
return;
|
|
|
|
}
|
2022-10-28 00:01:38 +02:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
os.apiWithDialog('following/create', {
|
|
|
|
userId: user.id,
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
const acct = new URL(location.href).searchParams.get('acct');
|
2022-09-03 09:16:00 +02:00
|
|
|
if (acct == null) {
|
|
|
|
throw new Error('acct required');
|
|
|
|
}
|
2020-10-18 03:11:34 +02:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
let promise;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
if (acct.startsWith('https://')) {
|
|
|
|
promise = os.api('ap/show', {
|
|
|
|
uri: acct,
|
|
|
|
});
|
|
|
|
promise.then(res => {
|
|
|
|
if (res.type === 'User') {
|
|
|
|
follow(res.object);
|
|
|
|
} else if (res.type === 'Note') {
|
|
|
|
mainRouter.push(`/notes/${res.object.id}`);
|
|
|
|
} else {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: 'Not a user',
|
|
|
|
}).then(() => {
|
2020-01-29 20:37:25 +01:00
|
|
|
window.close();
|
|
|
|
});
|
2022-09-01 17:22:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
promise = os.api('users/show', Acct.parse(acct));
|
|
|
|
promise.then(user => {
|
|
|
|
follow(user);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|