Fix localStorage usage

This commit is contained in:
Andrew Bastin
2021-06-21 00:27:45 -04:00
parent 257e2db651
commit f4f29b8520
10 changed files with 81 additions and 38 deletions

View File

@@ -167,6 +167,7 @@
<script>
import intializePwa from "~/helpers/pwa"
import { currentUser$ } from "~/helpers/fb/auth"
import { getLocalConfig, setLocalConfig } from "~/newstore/localpersistence"
// import { hasExtensionInstalled } from "~/helpers/strategies/ExtensionStrategy"
export default {
@@ -192,7 +193,7 @@ export default {
// Initializes the PWA code - checks if the app is installed,
// etc.
this.showInstallPrompt = await intializePwa()
const cookiesAllowed = localStorage.getItem("cookiesAllowed") === "yes"
const cookiesAllowed = getLocalConfig("cookiesAllowed") === "yes"
if (!cookiesAllowed) {
this.$toast.show(this.$t("we_use_cookies"), {
icon: "info",
@@ -202,7 +203,7 @@ export default {
{
text: this.$t("dismiss"),
onClick: (_, toastObject) => {
localStorage.setItem("cookiesAllowed", "yes")
setLocalConfig("cookiesAllowed", "yes")
toastObject.goAway(0)
},
},

View File

@@ -70,6 +70,7 @@
<script>
import { currentUser$, signInWithEmail } from "~/helpers/fb/auth"
import { setLocalConfig } from "~/newstore/localpersistence"
export default {
props: {
@@ -101,7 +102,7 @@ export default {
await signInWithEmail(this.form.email, actionCodeSettings)
.then(() => {
this.mode = "email"
window.localStorage.setItem("emailForSignIn", this.form.email)
setLocalConfig("emailForSignIn", this.form.email)
})
.catch((error) => {
this.$toast.error(error.message, {

View File

@@ -39,10 +39,12 @@
</template>
<script>
import { getLocalConfig, setLocalConfig } from "~/newstore/localpersistence"
export default {
data() {
return {
active: localStorage.getItem("THEME_COLOR") || "green",
active: getLocalConfig("THEME_COLOR") || "green",
accentColors: [
"blue",
"green",
@@ -58,7 +60,7 @@ export default {
},
watch: {
active(color) {
localStorage.setItem("THEME_COLOR", color)
setLocalConfig("THEME_COLOR", color)
},
},