mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-25 23:43:09 +02:00
7881f06be0
* refactor: deprecate i18n.t * revert: deprecate i18n.t This reverts commit 7dbf873a2f745040ee723df5db659acacff84e12. * chore: reimpl
71 lines
1.5 KiB
Vue
71 lines
1.5 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { } from 'vue';
|
|
import * as Misskey from 'misskey-js';
|
|
import * as os from '@/os.js';
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
|
import { i18n } from '@/i18n.js';
|
|
import { defaultStore } from '@/store.js';
|
|
import { mainRouter } from '@/global/router/main.js';
|
|
|
|
async function follow(user): Promise<void> {
|
|
const { canceled } = await os.confirm({
|
|
type: 'question',
|
|
text: i18n.tsx.followConfirm({ name: user.name || user.username }),
|
|
});
|
|
|
|
if (canceled) {
|
|
window.close();
|
|
return;
|
|
}
|
|
|
|
os.apiWithDialog('following/create', {
|
|
userId: user.id,
|
|
withReplies: defaultStore.state.defaultWithReplies,
|
|
});
|
|
user.withReplies = defaultStore.state.defaultWithReplies;
|
|
}
|
|
|
|
const acct = new URL(location.href).searchParams.get('acct');
|
|
if (acct == null) {
|
|
throw new Error('acct required');
|
|
}
|
|
|
|
let promise;
|
|
|
|
if (acct.startsWith('https://')) {
|
|
promise = misskeyApi('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(() => {
|
|
window.close();
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
promise = misskeyApi('users/show', Misskey.acct.parse(acct));
|
|
promise.then(user => {
|
|
follow(user);
|
|
});
|
|
}
|
|
|
|
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
|
</script>
|