Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LS cleanup #116

Open
BerkliumBirb opened this issue Oct 6, 2024 · 4 comments
Open

Implement LS cleanup #116

BerkliumBirb opened this issue Oct 6, 2024 · 4 comments

Comments

@BerkliumBirb
Copy link

In @logux/[email protected] localStorage may be clogged with old client identities.

view of dev tools with localStorage

image

Is there a way to clean up this?

@ai
Copy link
Member

ai commented Oct 6, 2024

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).

@BerkliumBirb
Copy link
Author

BerkliumBirb commented Oct 6, 2024

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

image

@ai
Copy link
Member

ai commented Oct 6, 2024

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.

@BerkliumBirb
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants