History

refactor(cloud): simplify authAtom type annotation

Rhys Sullivan committed 7 months ago

Commit aa604e21 parent 9d648ec1 file · +2 −7Browse files

Unified · Split

apps/cloud/src/web/auth.tsx+2−7
@@ -1,5 +1,5 @@
1import React, { createContext, useContext } from "react";1import React, { createContext, useContext } from "react";
2import { Atom, useAtomValue, Result } from "@effect-atom/atom-react";2import { useAtomValue, Result } from "@effect-atom/atom-react";
3 3
4import { CloudApiClient } from "./client";4import { CloudApiClient } from "./client";
5 5
@@ -19,16 +19,11 @@ type AuthTeam = { · 13 unmodified lines
19 name: string;19 name: string;
20};20};
21 21
22type MeResponse = {
23 user: AuthUser;
24 team: AuthTeam | null;
25};
26
27// ---------------------------------------------------------------------------22// ---------------------------------------------------------------------------
28// Auth atom — typed query against CloudAuthApi23// Auth atom — typed query against CloudAuthApi
29// ---------------------------------------------------------------------------24// ---------------------------------------------------------------------------
30 25
31export const authAtom: Atom.Atom<Result.Result<MeResponse, unknown>> =26export const authAtom: ReturnType<typeof CloudApiClient.query<"cloudAuth", "me">> =
32 CloudApiClient.query("cloudAuth", "me", {27 CloudApiClient.query("cloudAuth", "me", {
33 timeToLive: "5 minutes",28 timeToLive: "5 minutes",
34 });29 });

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t