mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 10:14:51 +00:00
refactor(ui): simplify setup-skip storage logic
Remove side-effect migration code, unnecessary encodeURIComponent, and implicit localStorage fallbacks from setup-skip utilities.
This commit is contained in:
1 parent
eaa0aecccf
commit
dc7f91b9f6
1 file changed
+4
-15
@@ -14,27 +14,16 @@ function getScopePart(value: string | null | undefined, fallback: string) {
|
||||
}
|
||||
|
||||
function getScopedSetupSkipKey(scope: SetupSkipScope) {
|
||||
const tenantScope = getScopePart(
|
||||
scope.tenantId ?? scope.tenantSlug ?? localStorage.getItem(LOCAL_STORAGE_KEYS.TENANT_ID),
|
||||
"default",
|
||||
);
|
||||
const userScope = getScopePart(
|
||||
scope.userId ?? localStorage.getItem(LOCAL_STORAGE_KEYS.USER_ID),
|
||||
"anonymous",
|
||||
);
|
||||
|
||||
return `${SETUP_SKIPPED_PREFIX}${encodeURIComponent(tenantScope)}:${encodeURIComponent(userScope)}`;
|
||||
const tenantScope = getScopePart(scope.tenantId ?? scope.tenantSlug, "default");
|
||||
const userScope = getScopePart(scope.userId, "anonymous");
|
||||
return `${SETUP_SKIPPED_PREFIX}${tenantScope}:${userScope}`;
|
||||
}
|
||||
|
||||
export function isSetupSkipped(scope: SetupSkipScope) {
|
||||
if (localStorage.getItem(LOCAL_STORAGE_KEYS.SETUP_SKIPPED) !== null) {
|
||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.SETUP_SKIPPED);
|
||||
}
|
||||
return localStorage.getItem(getScopedSetupSkipKey(scope)) === "1";
|
||||
}
|
||||
|
||||
export function markSetupSkipped(scope: SetupSkipScope) {
|
||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.SETUP_SKIPPED);
|
||||
localStorage.setItem(getScopedSetupSkipKey(scope), "1");
|
||||
}
|
||||
|
||||
@@ -43,7 +32,7 @@ export function clearSetupSkippedState() {
|
||||
for (let i = 0; i < localStorage.length; i += 1) {
|
||||
const key = localStorage.key(i);
|
||||
if (!key) continue;
|
||||
if (key === LOCAL_STORAGE_KEYS.SETUP_SKIPPED || key.startsWith(SETUP_SKIPPED_PREFIX)) {
|
||||
if (key.startsWith(SETUP_SKIPPED_PREFIX)) {
|
||||
keysToRemove.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user