Sharkey/packages/frontend/src/pages/follow.vue
syuilo 1f7a81aae7
update deps (#11764)
* update deps

* node16

* wip

* wip

* wip

* Update test-utils.ts

* wip

* Update tsconfig.json

* wip

* Update package.json

* wip

* Update following.vue

* Update followers.vue

* Update index.vue

* Update share.vue

* Update MkUserPopup.vue

* Update MkPostForm.vue

* wip

* Update MkTokenGenerateWindow.vue

* Update MkPagination.vue

* refactor

* update deps

* update deps

* Update sw.ts

* wip

* wip

* wip

* Update FetchInstanceMetadataService.ts

* Update FetchInstanceMetadataService.ts

* update node

* update deps

* 🎨
2023-09-04 13:33:38 +09:00

68 lines
1.3 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';
import { mainRouter } from '@/router';
import { i18n } from '@/i18n';
async function follow(user): Promise<void> {
const { canceled } = await os.confirm({
type: 'question',
text: i18n.t('followConfirm', { name: user.name || user.username }),
});
if (canceled) {
window.close();
return;
}
os.apiWithDialog('following/create', {
userId: user.id,
});
}
const acct = new URL(location.href).searchParams.get('acct');
if (acct == null) {
throw new Error('acct required');
}
let promise;
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(() => {
window.close();
});
}
});
} else {
promise = os.api('users/show', Misskey.acct.parse(acct));
promise.then(user => {
follow(user);
});
}
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
</script>