client
client copied to clipboard
Implement LS cleanup
In @logux/[email protected] localStorage may be clogged with old client identities.
view of dev tools with localStorage
Is there a way to clean up this?
Seems like a bug. Can you post the full name of the key, what browser and how exactly do you use Logux (what log storage, how create Logux client).
FF 130.
import { CrossTabClient, IndexedStore } from "@logux/client";
import { LocalPair } from "@logux/core";
import { nanoid } from "nanoid";
const pair = new LocalPair();
export const loguxClient = new CrossTabClient({
store: new IndexedStore(),
server: pair.left,
subprotocol: "1.0.0",
userId: nanoid(),
});
// Some loguxClient.type("...", ...) calls
loguxClient.start();
localStorage keys
Got it. The problem is because you create unique user ID every time.
userId: nanoid(),
In this case you need to call client.destroy() to clean all data.
We can't add built-in feature because most of the users need opposite, the persistence local-first data with real user ID from database.
I tried to use "stable" userId (saving it into localStorage), but it doesn't seem to solve the problem. Will report when have more info about it.