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 { LocalStorage } from "../local_storage";
|
||||
import { Result, type Result as ResultT } from "../result";
|
||||
import { Result, type Result as ResultT } from "@/utils/result";
|
||||
import { StorageKeys } from "../storage_keys";
|
||||
|
||||
export class AppStorage {
|
||||
@@ -78,7 +78,7 @@ export class AppStorage {
|
||||
todayString: string,
|
||||
): Promise<ResultT<boolean>> {
|
||||
const r = await AppStorage.ls.getString(key);
|
||||
if (r.kind === "failure") return r;
|
||||
return Result.success(r.value === null || r.value !== todayString);
|
||||
if (!r.success) return r;
|
||||
return Result.ok(r.data === null || r.data !== todayString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user