From b9c7857c5bb16d024fed6544eebf0ef6cd10390f Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sat, 14 Sep 2024 13:26:50 +0100
Subject: feature(mobile): Add proper error handling for server errors

---
 apps/mobile/app/dashboard/(tabs)/search.tsx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

(limited to 'apps/mobile/app/dashboard/(tabs)/search.tsx')

diff --git a/apps/mobile/app/dashboard/(tabs)/search.tsx b/apps/mobile/app/dashboard/(tabs)/search.tsx
index ee029ab8..d29c3b05 100644
--- a/apps/mobile/app/dashboard/(tabs)/search.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/search.tsx
@@ -1,6 +1,7 @@
 import { useState } from "react";
 import { View } from "react-native";
 import BookmarkList from "@/components/bookmarks/BookmarkList";
+import FullPageError from "@/components/FullPageError";
 import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";
 import FullPageSpinner from "@/components/ui/FullPageSpinner";
 import { Input } from "@/components/ui/Input";
@@ -16,10 +17,15 @@ export default function Search() {
 
   const onRefresh = api.useUtils().bookmarks.searchBookmarks.invalidate;
 
-  const { data, isPending } = api.bookmarks.searchBookmarks.useQuery(
-    { text: query },
-    { placeholderData: keepPreviousData },
-  );
+  const { data, error, refetch, isPending } =
+    api.bookmarks.searchBookmarks.useQuery(
+      { text: query },
+      { placeholderData: keepPreviousData },
+    );
+
+  if (error) {
+    return <FullPageError error={error.message} onRetry={() => refetch()} />;
+  }
 
   if (!data) {
     return <FullPageSpinner />;
-- 
cgit v1.2.3-70-g09d2

