diff options
| author | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
| commit | 46b78eaac30be26fe40520e97786563344af8403 (patch) | |
| tree | c4c0e1ae1d3d21a6f1fbf5f44f68e99243bbb5d3 /apps/mobile | |
| parent | 853ed13450b3a0d92cba144cc0dfd0696e7c810c (diff) | |
| download | karakeep-46b78eaac30be26fe40520e97786563344af8403.tar.zst | |
format: Add missing lint and format, and format the entire repo
Diffstat (limited to 'apps/mobile')
| -rw-r--r-- | apps/mobile/app.json | 5 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/_layout.tsx | 4 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/index.tsx | 13 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/lists.tsx | 8 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/search.tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/(tabs)/settings.tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/archive.tsx | 7 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/favourites.tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/lists/[slug].tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/app/dashboard/tags/[slug].tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/app/index.tsx | 18 | ||||
| -rw-r--r-- | apps/mobile/app/signin.tsx | 4 | ||||
| -rw-r--r-- | apps/mobile/components/Logo.tsx | 17 | ||||
| -rw-r--r-- | apps/mobile/components/bookmarks/BookmarkList.tsx | 8 | ||||
| -rw-r--r-- | apps/mobile/components/ui/PageTitle.tsx | 2 | ||||
| -rw-r--r-- | apps/mobile/index.ts | 2 | ||||
| -rw-r--r-- | apps/mobile/lib/upload.ts | 48 | ||||
| -rw-r--r-- | apps/mobile/package.json | 1 | ||||
| -rw-r--r-- | apps/mobile/tailwind.config.ts | 1 |
19 files changed, 74 insertions, 74 deletions
diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 028286e4..fec59de5 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -39,10 +39,7 @@ "NSExtensionActivationSupportsMovieWithMaxCount": 0, "NSExtensionActivationSupportsText": true }, - "androidIntentFilters": [ - "text/*", - "image/*" - ] + "androidIntentFilters": ["text/*", "image/*"] } ], "expo-secure-store", diff --git a/apps/mobile/app/dashboard/(tabs)/_layout.tsx b/apps/mobile/app/dashboard/(tabs)/_layout.tsx index fe40215e..7967b5c6 100644 --- a/apps/mobile/app/dashboard/(tabs)/_layout.tsx +++ b/apps/mobile/app/dashboard/(tabs)/_layout.tsx @@ -1,8 +1,8 @@ import React, { useEffect } from "react"; +import { Platform } from "react-native"; +import * as NavigationBar from "expo-navigation-bar"; import { Tabs } from "expo-router"; import { ClipboardList, Home, Search, Settings } from "lucide-react-native"; -import { Platform } from "react-native"; -import * as NavigationBar from 'expo-navigation-bar'; export default function TabLayout() { useEffect(() => { diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsx index 804eb0b5..5dccc845 100644 --- a/apps/mobile/app/dashboard/(tabs)/index.tsx +++ b/apps/mobile/app/dashboard/(tabs)/index.tsx @@ -3,21 +3,21 @@ import * as Haptics from "expo-haptics"; import * as ImagePicker from "expo-image-picker"; import { useRouter } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import PageTitle from "@/components/ui/PageTitle"; +import { useToast } from "@/components/ui/Toast"; import useAppSettings from "@/lib/settings"; import { useUploadAsset } from "@/lib/upload"; import { MenuView } from "@react-native-menu/menu"; import { SquarePen } from "lucide-react-native"; -import { useToast } from "@/components/ui/Toast"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; function HeaderRight() { - const {toast} = useToast(); + const { toast } = useToast(); const router = useRouter(); const { settings } = useAppSettings(); const { uploadAsset } = useUploadAsset(settings, { onError: (e) => { - toast({message: e, variant: "destructive"}); + toast({ message: e, variant: "destructive" }); }, }); return ( @@ -69,7 +69,10 @@ function HeaderRight() { shouldOpenOnLongPress={false} > <View className="my-auto px-4"> - <SquarePen color="rgb(0, 122, 255)" onPress={() => Haptics.selectionAsync()} /> + <SquarePen + color="rgb(0, 122, 255)" + onPress={() => Haptics.selectionAsync()} + /> </View> </MenuView> ); diff --git a/apps/mobile/app/dashboard/(tabs)/lists.tsx b/apps/mobile/app/dashboard/(tabs)/lists.tsx index 0350ebd2..767b9256 100644 --- a/apps/mobile/app/dashboard/(tabs)/lists.tsx +++ b/apps/mobile/app/dashboard/(tabs)/lists.tsx @@ -1,10 +1,10 @@ import { useEffect, useState } from "react"; import { FlatList, Pressable, Text, View } from "react-native"; import { Link } from "expo-router"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; import { ChevronRight } from "lucide-react-native"; -import PageTitle from "@/components/ui/PageTitle"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Lists() { const [refreshing, setRefreshing] = useState(false); @@ -51,9 +51,7 @@ export default function Lists() { return ( <CustomSafeAreaView> <FlatList - ListHeaderComponent={ - <PageTitle title="Lists" /> - } + ListHeaderComponent={<PageTitle title="Lists" />} contentContainerStyle={{ gap: 5, }} diff --git a/apps/mobile/app/dashboard/(tabs)/search.tsx b/apps/mobile/app/dashboard/(tabs)/search.tsx index bcaee5af..0a4dcbfd 100644 --- a/apps/mobile/app/dashboard/(tabs)/search.tsx +++ b/apps/mobile/app/dashboard/(tabs)/search.tsx @@ -1,13 +1,13 @@ import { useState } from "react"; import { View } from "react-native"; import BookmarkList from "@/components/bookmarks/BookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import { Input } from "@/components/ui/Input"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; import { keepPreviousData } from "@tanstack/react-query"; import { useDebounce } from "use-debounce"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Search() { const [search, setSearch] = useState(""); diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx index 0dbf7da6..c2db2846 100644 --- a/apps/mobile/app/dashboard/(tabs)/settings.tsx +++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx @@ -1,9 +1,9 @@ import { Text, View } from "react-native"; import { Button } from "@/components/ui/Button"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import PageTitle from "@/components/ui/PageTitle"; import { useSession } from "@/lib/session"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Dashboard() { const { logout } = useSession(); diff --git a/apps/mobile/app/dashboard/archive.tsx b/apps/mobile/app/dashboard/archive.tsx index e622a3e4..2fe5d274 100644 --- a/apps/mobile/app/dashboard/archive.tsx +++ b/apps/mobile/app/dashboard/archive.tsx @@ -1,11 +1,14 @@ import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; -import PageTitle from "@/components/ui/PageTitle"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; export default function Archive() { return ( <CustomSafeAreaView> - <UpdatingBookmarkList query={{archived: true}} header={<PageTitle title="🗄️ Archive" />} /> + <UpdatingBookmarkList + query={{ archived: true }} + header={<PageTitle title="🗄️ Archive" />} + /> </CustomSafeAreaView> ); } diff --git a/apps/mobile/app/dashboard/favourites.tsx b/apps/mobile/app/dashboard/favourites.tsx index 213cc918..abda5cfa 100644 --- a/apps/mobile/app/dashboard/favourites.tsx +++ b/apps/mobile/app/dashboard/favourites.tsx @@ -1,6 +1,6 @@ import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; -import PageTitle from "@/components/ui/PageTitle"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; export default function Favourites() { return ( diff --git a/apps/mobile/app/dashboard/lists/[slug].tsx b/apps/mobile/app/dashboard/lists/[slug].tsx index c0b86a0f..d42cc653 100644 --- a/apps/mobile/app/dashboard/lists/[slug].tsx +++ b/apps/mobile/app/dashboard/lists/[slug].tsx @@ -1,10 +1,10 @@ import { View } from "react-native"; import { Stack, useLocalSearchParams } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function ListView() { const { slug } = useLocalSearchParams(); diff --git a/apps/mobile/app/dashboard/tags/[slug].tsx b/apps/mobile/app/dashboard/tags/[slug].tsx index 26aa47ec..ea1ef63d 100644 --- a/apps/mobile/app/dashboard/tags/[slug].tsx +++ b/apps/mobile/app/dashboard/tags/[slug].tsx @@ -1,10 +1,10 @@ import { View } from "react-native"; import { Stack, useLocalSearchParams } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function TagView() { const { slug } = useLocalSearchParams(); diff --git a/apps/mobile/app/index.tsx b/apps/mobile/app/index.tsx index 235b19e4..dbbea97e 100644 --- a/apps/mobile/app/index.tsx +++ b/apps/mobile/app/index.tsx @@ -1,16 +1,16 @@ -import { useIsLoggedIn } from "@/lib/session"; import { Redirect } from "expo-router"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; +import { useIsLoggedIn } from "@/lib/session"; export default function App() { const isLoggedIn = useIsLoggedIn(); - if (isLoggedIn === undefined) { - // Wait until it's loaded - return <FullPageSpinner />; - } else if (isLoggedIn) { - return <Redirect href="dashboard" /> - } else { - return <Redirect href="signin" /> - } + if (isLoggedIn === undefined) { + // Wait until it's loaded + return <FullPageSpinner />; + } else if (isLoggedIn) { + return <Redirect href="dashboard" />; + } else { + return <Redirect href="signin" />; + } } diff --git a/apps/mobile/app/signin.tsx b/apps/mobile/app/signin.tsx index 2255424e..8402bd43 100644 --- a/apps/mobile/app/signin.tsx +++ b/apps/mobile/app/signin.tsx @@ -69,9 +69,7 @@ export default function Signin() { value={settings.address} autoCapitalize="none" keyboardType="url" - onChangeText={(e) => - setSettings({ ...settings, address: e }) - } + onChangeText={(e) => setSettings({ ...settings, address: e })} /> </View> <View className="gap-2"> diff --git a/apps/mobile/components/Logo.tsx b/apps/mobile/components/Logo.tsx index 9fdd1083..ba949ed4 100644 --- a/apps/mobile/components/Logo.tsx +++ b/apps/mobile/components/Logo.tsx @@ -1,11 +1,9 @@ -import * as React from "react" -import type { SvgProps} from "react-native-svg"; -import Svg, { Path } from "react-native-svg" +import type { SvgProps } from "react-native-svg"; +import * as React from "react"; +import Svg, { Path } from "react-native-svg"; + const Logo = (props: SvgProps) => ( - <Svg - viewBox="0 0 507 96" - {...props} - > + <Svg viewBox="0 0 507 96" {...props}> <Path d="M341.09 287.81c-.72-2.79-1.89-5.27-3.51-7.42s-3.74-3.9-6.34-5.26-6.5-2.32-10.33-2.04c-14.17 1.03-14.91 13.45-16.19 15.72l-.23-7v-24.46h-19.44v73.7h19.44v-22.5c0-3.4.89-7.2 2.63-9.5 1.73-2.3 4.2-2.5 7.45-2.5 1.66 0 3.01.32 4.07.96s1.91 1.51 2.55 2.6c.64 1.1 1.07 2.36 1.3 3.8.23 1.43.34 2.94.34 4.52v22.62h19.33v-34.87c0-2.79-.36-5.58-1.07-8.37m68.79 1.58c-1.66-3.69-3.92-6.83-6.79-9.39-2.87-2.57-6.19-4.53-9.96-5.89-3.78-1.36-7.81-2.04-12.11-2.04s-8.25.68-12.06 2.04-7.13 3.32-9.96 5.89c-2.83 2.56-5.07 5.7-6.73 9.39q-2.49 5.55-2.49 12.45c0 4.6.83 8.78 2.49 12.51 1.66 3.74 3.9 6.91 6.73 9.51s6.15 4.62 9.96 6.05q5.715 2.16 12.06 2.16c4.23 0 8.33-.72 12.11-2.16 3.77-1.43 7.09-3.45 9.96-6.05s5.13-5.77 6.79-9.51q2.49-5.595 2.49-12.51c0-4.61-.83-8.75-2.49-12.45m-16.24 17.77c-.57 1.74-1.42 3.31-2.55 4.7-1.13 1.4-2.53 2.51-4.19 3.34s-3.58 1.24-5.77 1.24-4.11-.41-5.77-1.24-3.06-1.94-4.19-3.34a14.6 14.6 0 0 1-2.55-4.7c-.56-1.73-.85-3.51-.85-5.32s.29-3.58.85-5.32c.57-1.73 1.4-3.26 2.49-4.58 1.1-1.32 2.47-2.4 4.13-3.23s3.59-1.24 5.78-1.24 4.11.41 5.77 1.24 3.06 1.91 4.19 3.23 2 2.85 2.6 4.58c.6 1.74.91 3.51.91 5.32s-.29 3.59-.85 5.32m73.12-18.62c-.95-3.73-2.44-6.83-4.47-9.28q-3.06-3.675-7.98-5.43c-3.29-1.17-7.3-1.76-12.06-1.76s-9.11.8-13.52 2.38c-4.42 1.59-8.29 3.96-11.61 7.13l9.4 10.08c1.73-1.59 3.83-2.95 6.28-4.08s5-1.7 7.64-1.7c2.87 0 5.28.66 7.25 1.98 1.96 1.33 2.94 3.38 2.94 6.17v.91c-4.08 0-8.26.22-12.57.68-4.3.45-8.2 1.36-11.71 2.71-3.51 1.36-6.38 3.29-8.6 5.78-2.23 2.49-3.34 5.77-3.34 9.84 0 3.33.64 6.12 1.92 8.38s2.93 4.08 4.93 5.43c1.99 1.36 4.2 2.34 6.62 2.95 2.41.6 4.75.9 7.01.9 3.4 0 5.93-.34 8.66-1.97 4.32-2.57 7.31-13.68 7.31-13.68l.33 8.28v6h16.98v-28.41c0-5.13-.47-9.56-1.41-13.3zm-15.57 19.08c0 3.54-1 6.35-2.99 8.43-2.01 2.07-4.89 3.11-8.66 3.11-.91 0-1.85-.09-2.83-.28-.99-.19-1.85-.51-2.61-.96a5.9 5.9 0 0 1-1.87-1.81c-.49-.76-.73-1.66-.73-2.72 0-1.66.53-3 1.58-4.02 1.06-1.02 2.4-1.79 4.02-2.32q2.43-.795 5.55-1.08c2.07-.18 4.13-.28 6.17-.28h2.37zm60.17-35.21c-.72-.07-1.46-.11-2.21-.11-3.47 0-6.53.91-9.17 2.74-2.64 1.82-4.68 10.18-6.11 13.06h-.23v-14.15h-17.88v56.14l18.56.22v-28.95c0-1.13.23-2.45.68-3.95.45-1.51 1.19-2.9 2.21-4.18s2.37-2.37 4.07-3.28c1.7-.9 3.79-1.35 6.28-1.35.76 0 1.53.04 2.32.11.67.07 1.36.18 2.05.36.13.03.26.06.39.1l.06-1.16.73-15.26c-.45-.15-1.04-.26-1.75-.34" transform="translate(-173 -247)" @@ -15,6 +13,5 @@ const Logo = (props: SvgProps) => ( transform="translate(-173 -247)" /> </Svg> -) -export default Logo - +); +export default Logo; diff --git a/apps/mobile/components/bookmarks/BookmarkList.tsx b/apps/mobile/components/bookmarks/BookmarkList.tsx index 9176f66d..7477992d 100644 --- a/apps/mobile/components/bookmarks/BookmarkList.tsx +++ b/apps/mobile/components/bookmarks/BookmarkList.tsx @@ -16,11 +16,11 @@ export default function BookmarkList({ isRefreshing, }: { bookmarks: ZBookmark[]; - onRefresh: () => void, - isRefreshing: boolean, - fetchNextPage?: () => void, + onRefresh: () => void; + isRefreshing: boolean; + fetchNextPage?: () => void; header?: React.ReactElement; - isFetchingNextPage?: boolean, + isFetchingNextPage?: boolean; }) { const flatListRef = useRef(null); useScrollToTop(flatListRef); diff --git a/apps/mobile/components/ui/PageTitle.tsx b/apps/mobile/components/ui/PageTitle.tsx index 1d1a8400..57b19e7d 100644 --- a/apps/mobile/components/ui/PageTitle.tsx +++ b/apps/mobile/components/ui/PageTitle.tsx @@ -1,4 +1,4 @@ -import {Text} from "react-native"; +import { Text } from "react-native"; export default function PageTitle({ title }: { title: string }) { return <Text className="p-4 text-4xl font-bold">{title}</Text>; diff --git a/apps/mobile/index.ts b/apps/mobile/index.ts index 5b834183..80d3d998 100644 --- a/apps/mobile/index.ts +++ b/apps/mobile/index.ts @@ -1 +1 @@ -import 'expo-router/entry'; +import "expo-router/entry"; diff --git a/apps/mobile/lib/upload.ts b/apps/mobile/lib/upload.ts index d511becc..56b2c7a5 100644 --- a/apps/mobile/lib/upload.ts +++ b/apps/mobile/lib/upload.ts @@ -1,38 +1,40 @@ import { useMutation } from "@tanstack/react-query"; +import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import { + zUploadErrorSchema, + zUploadResponseSchema, +} from "@hoarder/trpc/types/uploads"; + import type { Settings } from "./settings"; import { api } from "./trpc"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import { zUploadResponseSchema, zUploadErrorSchema } from "@hoarder/trpc/types/uploads"; export function useUploadAsset( settings: Settings, - options: { onSuccess?: (bookmark: ZBookmark) => void; onError?: (e: string) => void }, + options: { + onSuccess?: (bookmark: ZBookmark) => void; + onError?: (e: string) => void; + }, ) { const invalidateAllBookmarks = api.useUtils().bookmarks.getBookmarks.invalidate; - const { - mutate: createBookmark, - isPending: isCreatingBookmark, - } = api.bookmarks.createBookmark.useMutation({ - onSuccess: (d) => { - invalidateAllBookmarks(); - if (options.onSuccess) { - options.onSuccess(d); - } - }, - onError: (e) => { - if (options.onError) { - options.onError(e.message); - } - }, - }); + const { mutate: createBookmark, isPending: isCreatingBookmark } = + api.bookmarks.createBookmark.useMutation({ + onSuccess: (d) => { + invalidateAllBookmarks(); + if (options.onSuccess) { + options.onSuccess(d); + } + }, + onError: (e) => { + if (options.onError) { + options.onError(e.message); + } + }, + }); - const { - mutate: uploadAsset, - isPending: isUploading, - } = useMutation({ + const { mutate: uploadAsset, isPending: isUploading } = useMutation({ mutationFn: async (file: { type: string; name: string; uri: string }) => { const formData = new FormData(); // @ts-expect-error This is a valid api in react native diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 15b2057b..04fd8821 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -8,6 +8,7 @@ "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", + "format": "prettier .", "lint": "eslint .", "typecheck": "tsc --noEmit" }, diff --git a/apps/mobile/tailwind.config.ts b/apps/mobile/tailwind.config.ts index 9eb1eb4a..8d6f3785 100644 --- a/apps/mobile/tailwind.config.ts +++ b/apps/mobile/tailwind.config.ts @@ -1,4 +1,5 @@ import type { Config } from "tailwindcss"; + import base from "@hoarder/tailwind-config/native"; const config = { |
