mirror of
https://github.com/requarks/wiki.git
synced 2026-10-12 05:54:49 -05:00
fix: handle blocked localStorage gracefully
This commit is contained in:
3 files changed
+21
-34
No files matched your search
@@ -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,16 +2,26 @@ 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: {},
|
||||
actions: {
|
||||
async fetchLocaleStrings (locale) {
|
||||
async fetchLocaleStrings(locale) {
|
||||
try {
|
||||
return API_CLIENT.get(`locales/${locale}/strings`).json()
|
||||
} catch (err) {
|
||||
@@ -19,14 +29,18 @@ export const useCommonStore = defineStore('common', {
|
||||
throw err
|
||||
}
|
||||
},
|
||||
setLocale (locale) {
|
||||
setLocale(locale) {
|
||||
this.$patch({
|
||||
locale,
|
||||
desiredLocale: locale
|
||||
})
|
||||
localStorage.setItem('locale', locale)
|
||||
try {
|
||||
localStorage.setItem('locale', locale)
|
||||
} catch {
|
||||
// -> Refused storage costs remembering the choice, not making it
|
||||
}
|
||||
},
|
||||
async loadBlocks (blocks = []) {
|
||||
async loadBlocks(blocks = []) {
|
||||
const toLoad = difference(blocks, this.blocksLoaded)
|
||||
for (const block of toLoad) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user