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:
viettranx committed 2026-03-23 17:50:01 +07:00
1 parent eaa0aecccf
commit dc7f91b9f6
1 file changed
+4 -15
+4 -15
View File
@@ -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);
}
}