Skip to content

Commit

Permalink
Format front
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Dec 2, 2023
1 parent 49d2255 commit 7dab3fd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
1 change: 0 additions & 1 deletion front/apps/web/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ App.getInitialProps = async (ctx: AppContext) => {

if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) };


const getUrl = Component.getFetchUrls;
const getLayoutUrl =
Component.getLayout && "Layout" in Component.getLayout
Expand Down
2 changes: 1 addition & 1 deletion front/packages/models/src/accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const AccountProvider = ({
}) => {
if (Platform.OS === "web" && typeof window === "undefined") {
const accs = ssrAccount
? [{ ...ssrAccount, selected: true, select: () => { }, remove: () => { } }]
? [{ ...ssrAccount, selected: true, select: () => {}, remove: () => {} }]
: [];
return (
<AccountContext.Provider value={accs}>
Expand Down
10 changes: 5 additions & 5 deletions front/packages/models/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ export const login = async (
}
};

export const getTokenWJ = async (account?: Account | null): Promise<[string, Token] | [null, null]> => {
if (account === undefined)
account = getCurrentAccount();
export const getTokenWJ = async (
account?: Account | null,
): Promise<[string, Token] | [null, null]> => {
if (account === undefined) account = getCurrentAccount();
if (!account) return [null, null];

if (account.token.expire_at <= new Date(new Date().getTime() + 10 * 1000)) {
Expand All @@ -81,8 +82,7 @@ export const getTokenWJ = async (account?: Account | null): Promise<[string, Tok
return [`${account.token.token_type} ${account.token.access_token}`, account.token];
};

export const getToken = async (): Promise<string | null> =>
(await getTokenWJ())[0];
export const getToken = async (): Promise<string | null> => (await getTokenWJ())[0];

export const logout = () => {
removeAccounts((x) => x.selected);
Expand Down
37 changes: 19 additions & 18 deletions front/packages/models/src/query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const kyooUrl =
Platform.OS !== "web"
? process.env.PUBLIC_BACK_URL
: typeof window === "undefined"
? process.env.KYOO_URL ?? "http://localhost:5000"
: "/api";
? process.env.KYOO_URL ?? "http://localhost:5000"
: "/api";

export let kyooApiUrl: string | null = kyooUrl || null;

Expand All @@ -50,13 +50,13 @@ export const queryFn = async <Data,>(
context:
| (QueryFunctionContext & { timeout?: number })
| {
path: (string | false | undefined | null)[];
body?: object;
method: "GET" | "POST" | "DELETE";
authenticated?: boolean;
apiUrl?: string;
timeout?: number;
},
path: (string | false | undefined | null)[];
body?: object;
method: "GET" | "POST" | "DELETE";
authenticated?: boolean;
apiUrl?: string;
timeout?: number;
},
type?: z.ZodType<Data>,
token?: string | null,
): Promise<Data> => {
Expand All @@ -72,8 +72,8 @@ export const queryFn = async <Data,>(
"path" in context
? (context.path.filter((x) => x) as string[])
: "pageParam" in context && context.pageParam
? [context.pageParam as string]
: (context.queryKey.filter((x, i) => x && i) as string[]),
? [context.pageParam as string]
: (context.queryKey.filter((x, i) => x && i) as string[]),
)
.join("/")
.replace("/?", "?");
Expand Down Expand Up @@ -109,7 +109,8 @@ export const queryFn = async <Data,>(
data = { errors: [error] } as KyooErrors;
}
console.log(
`Invalid response (${"method" in context && context.method ? context.method : "GET"
`Invalid response (${
"method" in context && context.method ? context.method : "GET"
} ${path}):`,
data,
resp.status,
Expand Down Expand Up @@ -173,8 +174,8 @@ export type QueryPage<Props = {}, Items = unknown> = ComponentType<
> & {
getFetchUrls?: (route: { [key: string]: string }, randomItems: Items[]) => QueryIdentifier<any>[];
getLayout?:
| QueryPage<{ page: ReactElement }>
| { Layout: QueryPage<{ page: ReactElement }>; props: object };
| QueryPage<{ page: ReactElement }>
| { Layout: QueryPage<{ page: ReactElement }>; props: object };
randomItems?: Items[];
};

Expand All @@ -186,10 +187,10 @@ const toQueryKey = <Data, Ret>(query: QueryIdentifier<Data, Ret>) => {
...prefix,
...query.path,
"?" +
Object.entries(query.params)
.filter(([_, v]) => v !== undefined)
.map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(",") : v}`)
.join("&"),
Object.entries(query.params)
.filter(([_, v]) => v !== undefined)
.map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(",") : v}`)
.join("&"),
];
} else {
return [...prefix, ...query.path];
Expand Down
6 changes: 5 additions & 1 deletion front/packages/ui/src/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export const LoginPage: QueryPage = () => {
<Button
text={t("login.login")}
onPress={async () => {
const { error } = await login("login", { username, password, apiUrl: cleanApiUrl(apiUrl) });
const { error } = await login("login", {
username,
password,
apiUrl: cleanApiUrl(apiUrl),
});
setError(error);
if (error) return;
router.replace("/", undefined, {
Expand Down
8 changes: 4 additions & 4 deletions front/packages/ui/src/player/components/left-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ const VolumeSlider = () => {
isMuted || volume == 0
? VolumeOff
: volume < 25
? VolumeMute
: volume < 65
? VolumeDown
: VolumeUp
? VolumeMute
: volume < 65
? VolumeDown
: VolumeUp
}
onPress={() => setMuted(!isMuted)}
{...tooltip(t("player.mute"), true)}
Expand Down

0 comments on commit 7dab3fd

Please sign in to comment.