From ec8e872f8d12ce7285fbbb16603a79a6725f4e2a Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 30 May 2020 11:05:13 -0700 Subject: [PATCH] fix: better error message for invalid instances (#1793) --- src/routes/_actions/addInstance.js | 12 ++++++++---- src/routes/_pages/settings/instances/add.html | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routes/_actions/addInstance.js b/src/routes/_actions/addInstance.js index 1cf0eeae..ce5f6678 100644 --- a/src/routes/_actions/addInstance.js +++ b/src/routes/_actions/addInstance.js @@ -8,6 +8,13 @@ import { updateCustomEmojiForInstance } from './emoji' import { database } from '../_database/database' import { DOMAIN_BLOCKS } from '../_static/blocks' +const GENERIC_ERROR = ` + Is this a valid Mastodon instance? Is a browser extension + blocking the request? Are you in private browsing mode? + If you believe this is a problem with your instance, please send + this link to the administrator of your instance.` + function createKnownError (message) { const err = new Error(message) err.knownError = true @@ -59,10 +66,7 @@ export async function logInToInstance () { } catch (err) { console.error(err) const error = `${err.message || err.name}. ` + - (err.knownError ? '' : (navigator.onLine - ? `Is this a valid Mastodon instance? Is a browser extension - blocking the request? Are you in private browsing mode?` - : 'Are you offline?')) + (err.knownError ? '' : (navigator.onLine ? GENERIC_ERROR : 'Are you offline?')) const { instanceNameInSearch } = store.get() store.set({ logInToInstanceError: error, diff --git a/src/routes/_pages/settings/instances/add.html b/src/routes/_pages/settings/instances/add.html index 502ddfe1..d8c22ac3 100644 --- a/src/routes/_pages/settings/instances/add.html +++ b/src/routes/_pages/settings/instances/add.html @@ -14,7 +14,7 @@ {#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch} {/if}