aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/lib
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-13 22:37:41 +0000
committerMohamed Bassem <me@mbassem.com>2024-03-14 16:40:45 +0000
commita03f1dc2ac25579df30e8cb59d2703110c3e564d (patch)
tree59315e73cd83dc391660071c70752cf23989b3da /apps/mobile/lib
parent04572a8e5081b1e4871e273cde9dbaaa44c52fe0 (diff)
downloadkarakeep-a03f1dc2ac25579df30e8cb59d2703110c3e564d.tar.zst
lint: Lint and format the entire repo with the new configs
Diffstat (limited to 'apps/mobile/lib')
-rw-r--r--apps/mobile/lib/providers.tsx12
-rw-r--r--apps/mobile/lib/session.ts2
-rw-r--r--apps/mobile/lib/settings.ts9
-rw-r--r--apps/mobile/lib/storage-state.ts6
-rw-r--r--apps/mobile/lib/trpc.ts3
-rw-r--r--apps/mobile/lib/utils.ts3
6 files changed, 18 insertions, 17 deletions
diff --git a/apps/mobile/lib/providers.tsx b/apps/mobile/lib/providers.tsx
index 1717afb2..036e8ae2 100644
--- a/apps/mobile/lib/providers.tsx
+++ b/apps/mobile/lib/providers.tsx
@@ -1,13 +1,12 @@
+import { useEffect, useState } from "react";
+import { ToastProvider } from "@/components/ui/Toast";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { httpBatchLink } from "@trpc/client";
-import { useEffect, useState } from "react";
import superjson from "superjson";
import useAppSettings, { getAppSettings } from "./settings";
import { api } from "./trpc";
-import { ToastProvider } from "@/components/ui/Toast";
-
function getTRPCClient(address: string) {
return api.createClient({
links: [
@@ -16,10 +15,9 @@ function getTRPCClient(address: string) {
async headers() {
const settings = await getAppSettings();
return {
- Authorization:
- settings && settings.apiKey
- ? `Bearer ${settings.apiKey}`
- : undefined,
+ Authorization: settings?.apiKey
+ ? `Bearer ${settings.apiKey}`
+ : undefined,
};
},
transformer: superjson,
diff --git a/apps/mobile/lib/session.ts b/apps/mobile/lib/session.ts
index e2ab245b..071748b9 100644
--- a/apps/mobile/lib/session.ts
+++ b/apps/mobile/lib/session.ts
@@ -10,7 +10,7 @@ export function useSession() {
const logout = useCallback(() => {
setSettings({ ...settings, apiKey: undefined });
- }, [settings]);
+ }, [settings, setSettings]);
return {
isLoggedIn,
diff --git a/apps/mobile/lib/settings.ts b/apps/mobile/lib/settings.ts
index 21f40528..13de067e 100644
--- a/apps/mobile/lib/settings.ts
+++ b/apps/mobile/lib/settings.ts
@@ -4,14 +4,15 @@ import { useStorageState } from "./storage-state";
const SETTING_NAME = "settings";
-export type Settings = {
+export interface Settings {
apiKey?: string;
address: string;
-};
+}
export default function useAppSettings() {
- let [[isLoading, settings], setSettings] =
- useStorageState<Settings>(SETTING_NAME);
+ const [settingsState, setSettings] = useStorageState<Settings>(SETTING_NAME);
+ const [isLoading] = settingsState;
+ let [, settings] = settingsState;
settings ||= {
address: "https://demo.hoarder.app",
diff --git a/apps/mobile/lib/storage-state.ts b/apps/mobile/lib/storage-state.ts
index 4988f0e0..f45ddfe5 100644
--- a/apps/mobile/lib/storage-state.ts
+++ b/apps/mobile/lib/storage-state.ts
@@ -1,5 +1,5 @@
-import * as SecureStore from "expo-secure-store";
import * as React from "react";
+import * as SecureStore from "expo-secure-store";
type UseStateHook<T> = [[boolean, T | null], (value: T | null) => void];
@@ -8,7 +8,7 @@ function useAsyncState<T>(
): UseStateHook<T> {
return React.useReducer(
(
- state: [boolean, T | null],
+ _state: [boolean, T | null],
action: T | null = null,
): [boolean, T | null] => [false, action],
initialValue,
@@ -34,7 +34,7 @@ export function useStorageState<T>(key: string): UseStateHook<T> {
setState(null);
return null;
}
- setState(JSON.parse(value));
+ setState(JSON.parse(value) as T);
});
}, [key]);
diff --git a/apps/mobile/lib/trpc.ts b/apps/mobile/lib/trpc.ts
index 6b428bd9..9b025df1 100644
--- a/apps/mobile/lib/trpc.ts
+++ b/apps/mobile/lib/trpc.ts
@@ -1,4 +1,5 @@
-import type { AppRouter } from "@hoarder/trpc/routers/_app";
import { createTRPCReact } from "@trpc/react-query";
+import type { AppRouter } from "@hoarder/trpc/routers/_app";
+
export const api = createTRPCReact<AppRouter>();
diff --git a/apps/mobile/lib/utils.ts b/apps/mobile/lib/utils.ts
index 365058ce..88283f01 100644
--- a/apps/mobile/lib/utils.ts
+++ b/apps/mobile/lib/utils.ts
@@ -1,4 +1,5 @@
-import { type ClassValue, clsx } from "clsx";
+import type { ClassValue } from "clsx";
+import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {