mirror of
https://github.com/ente-io/ente.git
synced 2025-08-07 23:18:10 +00:00
Funnel point
This commit is contained in:
parent
05e7a998e2
commit
4acd17f06b
@ -1,6 +1,8 @@
|
||||
// TODO: This file belongs to the accounts package
|
||||
import { z } from "zod";
|
||||
|
||||
// TODO: During login the only field present is email. Which makes this
|
||||
// optionality indicated by these types incorrect.
|
||||
const LocalUser = z.object({
|
||||
/** The user's ID. */
|
||||
id: z.number(),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import log from "@/next/log";
|
||||
import { removeKV, setKV } from "packages/next/kv";
|
||||
|
||||
export enum LS_KEYS {
|
||||
USER = "user",
|
||||
@ -46,3 +47,16 @@ export const getData = (key: LS_KEYS) => {
|
||||
};
|
||||
|
||||
export const clearData = () => localStorage.clear();
|
||||
|
||||
// TODO: Migrate this to `local-user.ts`, with (a) more precise optionality
|
||||
// indication of the constituent fields, (b) moving any fields that need to be
|
||||
// accessed from web workers to KV DB.
|
||||
//
|
||||
// Creating a new function here to act as a funnel point.
|
||||
export const setLSUser = (user: object) => {
|
||||
const token = user["token"];
|
||||
token && typeof token == "string"
|
||||
? setKV("token", token)
|
||||
: removeKV("token");
|
||||
setData(LS_KEYS.USER, user);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user