fix: handle blocked localStorage gracefully

scarlett
NGPixel 23 hours ago
parent f15180608a
commit 55e325d2a7
No known key found for this signature in database

@ -100,9 +100,8 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
# After the image push, so that no published chart ever names an image that is not there
- name: Set up Helm
uses: azure/setup-helm@v4
uses: azure/setup-helm@v5
- name: Package and push Helm chart
env:

@ -1,26 +0,0 @@
name: Helm Chart CI
on:
# Triggers the workflow on push or pull request events but only for the dev branch
push:
branches: [ main ]
paths: [ dev/helm/** ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Update Chart
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Package and Push Chart
run: |
helm plugin install https://github.com/chartmuseum/helm-push.git
helm repo add chartmuseum https://charts.js.wiki
helm cm-push --version="2.2.${{github.run_number}}" --username="${{secrets.HELM_REPO_USERNAME}}" --password="${{secrets.HELM_REPO_PASSWORD}}" dev/helm/ chartmuseum
helm repo remove chartmuseum

@ -2,11 +2,21 @@ import { defineStore } from 'pinia'
import { difference } from 'es-toolkit/array'
// -> A browser blocking site data throws on merely reading `localStorage`, and a throw here
// happens while the store is created, which leaves the whole app unmounted
function storedLocale() {
try {
return localStorage.getItem('locale')
} catch {
return null
}
}
export const useCommonStore = defineStore('common', {
state: () => ({
routerLoading: false,
locale: localStorage.getItem('locale') || 'en',
desiredLocale: localStorage.getItem('locale'),
locale: storedLocale() || 'en',
desiredLocale: storedLocale(),
blocksLoaded: []
}),
getters: {},
@ -24,7 +34,11 @@ export const useCommonStore = defineStore('common', {
locale,
desiredLocale: locale
})
try {
localStorage.setItem('locale', locale)
} catch {
// -> Refused storage costs remembering the choice, not making it
}
},
async loadBlocks(blocks = []) {
const toLoad = difference(blocks, this.blocksLoaded)

Loading…
Cancel
Save