fix: error msg when logging in to same instance (#735)

This commit is contained in:
Nolan Lawson 2018-12-05 21:34:02 -08:00 committed by GitHub
parent f7164dd4c0
commit c0f857336a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -14,8 +14,9 @@ async function redirectToOauth () {
let { instanceNameInSearch, loggedInInstances } = store.get()
instanceNameInSearch = instanceNameInSearch.replace(/^https?:\/\//, '').replace(/\/$/, '').replace('/$', '').toLowerCase()
if (Object.keys(loggedInInstances).includes(instanceNameInSearch)) {
store.set({ logInToInstanceError: `You've already logged in to ${instanceNameInSearch}` })
return
let err = new Error(`You've already logged in to ${instanceNameInSearch}`)
err.knownError = true
throw err
}
let registrationPromise = registerApplication(instanceNameInSearch, REDIRECT_URI)
let instanceInfo = await getInstanceInfo(instanceNameInSearch)
@ -44,10 +45,10 @@ export async function logInToInstance () {
} catch (err) {
console.error(err)
let error = `${err.message || err.name}. ` +
(navigator.onLine
(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?`)
: `Are you offline?`))
let { instanceNameInSearch } = store.get()
store.set({
logInToInstanceError: error,