2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:50:11 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-05-19 09:20:53 +02:00
|
|
|
<div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2023-09-04 06:33:38 +02:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { defaultStore } from '@/store.js';
|
2024-01-30 13:07:34 +01:00
|
|
|
import { mainRouter } from '@/router/main.js';
|
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',
|
2024-01-20 00:11:59 +01:00
|
|
|
text: i18n.tsx.followConfirm({ name: user.name || user.username }),
|
2022-09-01 17:22:31 +02:00
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
if (canceled) {
|
|
|
|
window.close();
|
|
|
|
return;
|
|
|
|
}
|
2023-07-08 00:08:16 +02:00
|
|
|
|
2022-09-01 17:22:31 +02:00
|
|
|
os.apiWithDialog('following/create', {
|
|
|
|
userId: user.id,
|
2023-10-17 13:56:17 +02:00
|
|
|
withReplies: defaultStore.state.defaultWithReplies,
|
2022-09-01 17:22:31 +02:00
|
|
|
});
|
2023-10-17 13:56:17 +02:00
|
|
|
user.withReplies = defaultStore.state.defaultWithReplies;
|
2022-09-01 17:22:31 +02:00
|
|
|
}
|
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://')) {
|
2024-01-04 10:32:46 +01:00
|
|
|
promise = misskeyApi('ap/show', {
|
2022-09-01 17:22:31 +02:00
|
|
|
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 {
|
2024-01-04 10:32:46 +01:00
|
|
|
promise = misskeyApi('users/show', Misskey.acct.parse(acct));
|
2022-09-01 17:22:31 +02:00
|
|
|
promise.then(user => {
|
|
|
|
follow(user);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|