Merge pull request #236 from tiqi-group/fix/local_storage_usage

fix: prefix localStorage key with authority id
This commit is contained in:
Mose Müller 2025-06-06 13:43:41 +02:00 committed by GitHub
commit 28a1cc7cd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 13 deletions

View File

@ -1,8 +1,9 @@
import { useState, useEffect } from "react";
import { authority } from "../socket";
export default function useLocalStorage(key: string, defaultValue: unknown) {
const [value, setValue] = useState(() => {
const storedValue = localStorage.getItem(key);
const storedValue = localStorage.getItem(`${authority}:${key}`);
if (storedValue) {
return JSON.parse(storedValue);
}
@ -11,7 +12,7 @@ export default function useLocalStorage(key: string, defaultValue: unknown) {
useEffect(() => {
if (value === undefined) return;
localStorage.setItem(key, JSON.stringify(value));
localStorage.setItem(`${authority}:${key}`, JSON.stringify(value));
}, [value, key]);
return [value, setValue];

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site displaying a pydase UI." />
<script type="module" crossorigin src="/assets/index-BLJetjaQ.js"></script>
<script type="module" crossorigin src="/assets/index-DK2ZYE8p.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DJzFvk4W.css">
</head>