fix: show warning when local storage is unavailable (#782)

fixes #780
This commit is contained in:
Nolan Lawson 2018-12-11 22:07:01 -08:00 committed by GitHub
parent e3f7b3e65c
commit 76a8072e04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -3,11 +3,11 @@
<form class="add-new-instance" on:submit='onSubmit(event)' aria-labelledby="add-an-instance-h1"> <form class="add-new-instance" on:submit='onSubmit(event)' aria-labelledby="add-an-instance-h1">
{#if !hasIndexedDB} {#if !hasIndexedDB || !hasLocalStorage}
<div class="form-error form-error-user-error" role="alert"> <div class="form-error form-error-user-error" role="alert">
Your browser doesn't support IndexedDB, possibly because it's in private browsing mode It seems Pinafore cannot store data locally. Is your browser in private mode
or blocking cookies. Pinafore stores all data locally, and requires IndexedDB to work or blocking cookies? Pinafore stores all data locally, and requires LocalStorage and
correctly. IndexedDB to work correctly.
</div> </div>
{/if} {/if}
@ -77,7 +77,7 @@
import { store } from '../../../_store/store' import { store } from '../../../_store/store'
import { logInToInstance, handleOauthCode } from '../../../_actions/addInstance' import { logInToInstance, handleOauthCode } from '../../../_actions/addInstance'
import ExternalLink from '../../../_components/ExternalLink.html' import ExternalLink from '../../../_components/ExternalLink.html'
import { testHasIndexedDB } from '../../../_utils/testStorage' import { testHasIndexedDB, testHasLocalStorage } from '../../../_utils/testStorage'
export default { export default {
async oncreate () { async oncreate () {
@ -85,8 +85,10 @@
if (codeMatch) { if (codeMatch) {
return handleOauthCode(codeMatch[1]) return handleOauthCode(codeMatch[1])
} }
let hasIndexedDB = await testHasIndexedDB() this.set({
this.set({ hasIndexedDB }) hasIndexedDB: await testHasIndexedDB(),
hasLocalStorage: testHasLocalStorage()
})
}, },
components: { components: {
SettingsLayout, SettingsLayout,
@ -94,7 +96,8 @@
}, },
store: () => store, store: () => store,
data: () => ({ data: () => ({
hasIndexedDB: true hasIndexedDB: true,
hasLocalStorage: true
}), }),
methods: { methods: {
onSubmit (event) { onSubmit (event) {