fix: add missing setup property, use done state in remote follow page

This commit is contained in:
Johann150 2022-07-28 13:10:52 +02:00
parent 1f3b3abf68
commit 8c198f648b
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -2,9 +2,10 @@
<!-- This page does not really have any content, it is mainly processing stuff --> <!-- This page does not really have any content, it is mainly processing stuff -->
<MkLoading v-if="state == 'loading'"/> <MkLoading v-if="state == 'loading'"/>
<MkError v-if="state == 'error'" :final="finalError" @retry="doIt"/> <MkError v-if="state == 'error'" :final="finalError" @retry="doIt"/>
<div v-if="state == 'done'">{{ i18n.ts.done }}</div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { } from 'vue'; import { } from 'vue';
import * as Acct from 'misskey-js/built/acct'; import * as Acct from 'misskey-js/built/acct';
import * as os from '@/os'; import * as os from '@/os';
@ -35,9 +36,10 @@ function doIt() {
state = 'loading'; state = 'loading';
const acct = new URL(location.href).searchParams.get('acct'); const acct = new URL(location.href).searchParams.get('acct');
if (acct == null) { if (acct == null || acct.trim() === '') {
finalError = true; finalError = true;
state = 'error'; state = 'error';
return;
} }
let promise; let promise;
@ -45,8 +47,7 @@ function doIt() {
if (acct.startsWith('https://')) { if (acct.startsWith('https://')) {
promise = os.api('ap/show', { promise = os.api('ap/show', {
uri: acct, uri: acct,
}); }).then(res => {
promise.then(res => {
if (res.type === 'User') { if (res.type === 'User') {
follow(res.object); follow(res.object);
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
@ -59,16 +60,16 @@ function doIt() {
finalError = true; finalError = true;
state = 'error'; state = 'error';
}); });
return;
} }
state = 'done';
}); });
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
} else { } else {
promise = os.api('users/show', Acct.parse(acct)); os.api('users/show', Acct.parse(acct))
promise.then(user => { .then(user => follow(user))
follow(user); .then(() => state = 'done');
});
} }
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
} }
doIt(); doIt();