refactor(data): move Result utility to utils and simplify API
Relocate the Result type from `@/data/result` to `@/utils/result` and replace the discriminated-union API (`kind`/`value`) with a simpler boolean-based API (`success`/`data`) across all repositories and storage classes for improved readability and consistency.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
import { UserSchema, type UserData } from "@/data/schemas/user/user";
|
||||
import { LocalStorage } from "../local_storage";
|
||||
import { type Result as ResultT } from "../result";
|
||||
import { type Result as ResultT } from "@/utils/result";
|
||||
import { StorageKeys } from "../storage_keys";
|
||||
import type { IUserStorage } from "./iuser_storage";
|
||||
|
||||
@@ -85,9 +85,9 @@ export class UserStorage implements IUserStorage {
|
||||
|
||||
async clearUserData(): Promise<ResultT<void>> {
|
||||
const r1 = await this.clearUser();
|
||||
if (r1.kind === "failure") return r1;
|
||||
if (!r1.success) return r1;
|
||||
const r2 = await this.clearUserId();
|
||||
if (r2.kind === "failure") return r2;
|
||||
if (!r2.success) return r2;
|
||||
return this.clearAvatarUrl();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user