diff --git a/packages/client/src/pages/follow-me.vue b/packages/client/src/pages/follow-me.vue index c3dd0217cf..80fb6de5a2 100644 --- a/packages/client/src/pages/follow-me.vue +++ b/packages/client/src/pages/follow-me.vue @@ -15,64 +15,60 @@ if (acctUri == null) { throw new Error("acct required"); } -let useThisAccount = isSignedIn(me) ? true : false; - // If the user is already logged in, ask whether to follow using the current account. -if (useThisAccount) { +if (isSignedIn(me)) { const { canceled } = await os.confirm({ type: "question", text: i18n.ts.useThisAccountConfirm, }); + + // use the current account if (!canceled) { waiting(); window.location.href = `/authorize-follow?acct=${acctUri}`; - } else { - useThisAccount = false; } } -if (!useThisAccount) { - // Ask the user what the account ID is - const remoteAccountId = await os.inputText({ - text: i18n.ts.inputAccountId, - }); +// Otherwise ask the user what the other account ID is +const remoteAccountId = await os.inputText({ + text: i18n.ts.inputAccountId, +}); - // If the user do not want enter uri, the user will be redirected to the user page. - if (!remoteAccountId.result) { +// If the user do not want enter uri, the user will be redirected to the user page. +if (!remoteAccountId.result) { + waiting(); + window.location.href = `/@${acctUri}`; +} else { + const remoteAcctInfo = acct.parse(remoteAccountId.result); + + // If the user on this server, redirect directly + if (remoteAcctInfo.host === hostRaw || remoteAcctInfo.host === null) { waiting(); - window.location.href = `/@${acctUri}`; + window.location.href = `/authorize-follow?acct=${acctUri}`; } else { - const remoteAcctInfo = acct.parse(remoteAccountId.result); - - // If the user on this server, redirect directly - if (remoteAcctInfo.host === hostRaw || remoteAcctInfo.host === null) { - waiting(); - window.location.href = `/authorize-follow?acct=${acctUri}`; - } else { - waiting(); - // If not, find the interaction url through webfinger interface - fetch( - `https://${remoteAcctInfo.host}/.well-known/webfinger?resource=${remoteAcctInfo.username}@${remoteAcctInfo.host}`, - { - method: "GET", - }, - ) - .then((response) => response.json()) - .then((data) => { - const subscribeUri = data.links.find( - (link) => link.rel === "http://ostatus.org/schema/1.0/subscribe", - ).template; - window.location.href = subscribeUri.replace( - "{uri}", - acctUri.includes("@") ? acctUri : `${acctUri}@${hostRaw}`, - ); - }) - .catch((e) => { - // TODO: It would be better to provide more information, but the priority of - // waiting component is too high and the pop-up window will be blocked. - window.location.href = `/@${acctUri}`; - }); - } + waiting(); + // If not, find the interaction url through webfinger interface + fetch( + `https://${remoteAcctInfo.host}/.well-known/webfinger?resource=${remoteAcctInfo.username}@${remoteAcctInfo.host}`, + { + method: "GET", + }, + ) + .then((response) => response.json()) + .then((data) => { + const subscribeUri = data.links.find( + (link: { rel: string; }) => link.rel === "http://ostatus.org/schema/1.0/subscribe", + ).template; + window.location.href = subscribeUri.replace( + "{uri}", + acctUri.includes("@") ? acctUri : `${acctUri}@${hostRaw}`, + ); + }) + .catch((_) => { + // TODO: It would be better to provide more information, but the priority of + // waiting component is too high and the pop-up window will be blocked. + window.location.href = `/@${acctUri}`; + }); } } </script>