2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
|
|
|
<div class="mk-follow-page">
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-01-29 20:37:25 +01:00
|
|
|
created() {
|
|
|
|
const acct = new URL(location.href).searchParams.get('acct');
|
|
|
|
if (acct == null) return;
|
|
|
|
|
2020-10-18 03:11:34 +02:00
|
|
|
let promise;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
if (acct.startsWith('https://')) {
|
2020-10-18 03:11:34 +02:00
|
|
|
promise = os.api('ap/show', {
|
2020-01-29 20:37:25 +01:00
|
|
|
uri: acct
|
2020-10-18 03:11:34 +02:00
|
|
|
});
|
|
|
|
promise.then(res => {
|
2022-05-26 15:53:09 +02:00
|
|
|
if (res.type === 'User') {
|
2020-01-29 20:37:25 +01:00
|
|
|
this.follow(res.object);
|
2020-10-17 18:46:40 +02:00
|
|
|
} else if (res.type === 'Note') {
|
|
|
|
this.$router.push(`/notes/${res.object.id}`);
|
2020-01-29 20:37:25 +01:00
|
|
|
} else {
|
2021-11-18 10:45:58 +01:00
|
|
|
os.alert({
|
2020-01-29 20:37:25 +01:00
|
|
|
type: 'error',
|
|
|
|
text: 'Not a user'
|
|
|
|
}).then(() => {
|
|
|
|
window.close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2021-11-11 18:02:25 +01:00
|
|
|
promise = os.api('users/show', Acct.parse(acct));
|
2020-10-18 03:11:34 +02:00
|
|
|
promise.then(user => {
|
2020-01-29 20:37:25 +01:00
|
|
|
this.follow(user);
|
|
|
|
});
|
|
|
|
}
|
2020-10-18 03:11:34 +02:00
|
|
|
|
2020-12-26 02:47:36 +01:00
|
|
|
os.promiseDialog(promise, null, null, this.$ts.fetchingAsApObject);
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async follow(user) {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled } = await os.confirm({
|
2020-01-29 20:37:25 +01:00
|
|
|
type: 'question',
|
|
|
|
text: this.$t('followConfirm', { name: user.name || user.username }),
|
|
|
|
});
|
|
|
|
|
|
|
|
if (canceled) {
|
|
|
|
window.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-18 03:11:34 +02:00
|
|
|
os.apiWithDialog('following/create', {
|
2020-01-29 20:37:25 +01:00
|
|
|
userId: user.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|