diff --git a/routes/_utils/asyncModules.js b/routes/_utils/asyncModules.js index c90e3b0..8f1c7b7 100644 --- a/routes/_utils/asyncModules.js +++ b/routes/_utils/asyncModules.js @@ -9,16 +9,11 @@ const importURLSearchParams = () => import( }) }) -const importToast = () => import( - /* webpackChunkName: 'toast' */ './toast' - ).then(mod => mod.toast) - const importTimeline = () => import( /* webpackChunkName: 'Timeline' */ '../_components/Timeline.html' ).then(mod => mod.default) export { importURLSearchParams, - importToast, importTimeline } \ No newline at end of file diff --git a/routes/settings/instances/[instanceName].html b/routes/settings/instances/[instanceName].html index b9abc4e..39ceeb1 100644 --- a/routes/settings/instances/[instanceName].html +++ b/routes/settings/instances/[instanceName].html @@ -96,7 +96,7 @@ import { themes } from '../../_static/themes' import { switchToTheme } from '../../_utils/themeEngine' import { goto } from 'sapper/runtime.js' - import { importToast } from '../../_utils/asyncModules' + import { toast } from '../../_utils/toast' export default { components: { @@ -159,7 +159,7 @@ }) this.store.save() switchToTheme(instanceThemes[newInstance] || 'default') - importToast().then(toast => toast.say(`Logged out of ${instanceName}`)) + toast.say(`Logged out of ${instanceName}`) goto('/settings/instances') } } diff --git a/routes/settings/instances/add.html b/routes/settings/instances/add.html index 70b3edf..afee805 100644 --- a/routes/settings/instances/add.html +++ b/routes/settings/instances/add.html @@ -57,7 +57,7 @@ import { store } from '../../_utils/store' import { goto } from 'sapper/runtime.js' import { switchToTheme } from '../../_utils/themeEngine' - import { importToast } from '../../_utils/asyncModules' + import { toast } from '../../_utils/toast' import LoadingMask from '../../_components/LoadingMask' const REDIRECT_URI = (typeof location !== 'undefined' ? @@ -90,8 +90,10 @@ if (process.env.NODE_ENV !== 'production') { console.error(err) } - const toast = await importToast() - toast.say(`Error: ${err.message || err.name}. Is this a valid Mastodon instance?`) + toast.say(`Error: ${err.message || err.name}. ` + + (navigator.onLine ? + `Is this a valid Mastodon instance?` : + `Are you offline?`)) } finally { this.set({loading: false}) } @@ -101,7 +103,6 @@ let loggedInInstances = this.store.get('loggedInInstances') instanceName = instanceName.replace(/^https?:\/\//, '').replace('/$', '') if (Object.keys(loggedInInstances).includes(instanceName)) { - const toast = await importToast() toast.say(`You've already logged in to ${instanceName}`) return } @@ -123,7 +124,6 @@ this.set({loading: true}) await this.registerNewInstance(code) } catch (err) { - const toast = await importToast() toast.say(`Error: ${err.message || err.name}. Failed to connect to instance.`) } finally { this.set({loading: false})