Only validate persisted data for existing users (#4465)
parent
5dd195bcb7
commit
7356763e49
|
@ -13,7 +13,13 @@ export async function write(value: Schema) {
|
||||||
export async function read(): Promise<Schema | undefined> {
|
export async function read(): Promise<Schema | undefined> {
|
||||||
const rawData = await AsyncStorage.getItem(BSKY_STORAGE)
|
const rawData = await AsyncStorage.getItem(BSKY_STORAGE)
|
||||||
const objData = rawData ? JSON.parse(rawData) : undefined
|
const objData = rawData ? JSON.parse(rawData) : undefined
|
||||||
|
|
||||||
|
// new user
|
||||||
|
if (!objData) return undefined
|
||||||
|
|
||||||
|
// existing user, validate
|
||||||
const parsed = schema.safeParse(objData)
|
const parsed = schema.safeParse(objData)
|
||||||
|
|
||||||
if (parsed.success) {
|
if (parsed.success) {
|
||||||
return objData
|
return objData
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue