@@ -39,7 +39,6 @@ export default function useSupabase() {
3939 category : "Supabase push" ,
4040 level : "info" ,
4141 message : `Pushing ${ unsyncedRecords . length } local database entries to supabase` ,
42- timestamp : Date . now ( ) ,
4342 } ) ;
4443
4544 const { data : authData , error : authError } =
@@ -60,7 +59,6 @@ export default function useSupabase() {
6059 level : "warning" ,
6160 message : errorMsg ,
6261 data : { authError : authError ?. message } ,
63- timestamp : Date . now ( ) ,
6462 } ) ;
6563
6664 // Update login status and exit gracefully
@@ -111,8 +109,13 @@ export default function useSupabase() {
111109 const syncFromSupabase = useCallback ( async ( ) => {
112110 if ( ! network || ! isLoggedInRef . current ) return ;
113111 try {
114- const { data : authData } = await supabase . auth . getUser ( ) ;
115- if ( ! authData ?. user ?. id ) throw new Error ( "User not authenticated" ) ;
112+ const { data : authData , error : authError } =
113+ await supabase . auth . getUser ( ) ;
114+
115+ if ( authError || ! authData ?. user ?. id ) {
116+ isLoggedInRef . current = false ;
117+ return ;
118+ }
116119
117120 const { error, data } = await supabase
118121 . from ( "search_history" )
@@ -126,7 +129,6 @@ export default function useSupabase() {
126129 category : "Supabase pull" ,
127130 level : "info" ,
128131 message : `Pulling ${ data . length } entries from supabase to local database` ,
129- timestamp : Date . now ( ) ,
130132 } ) ;
131133
132134 if ( data ) {
@@ -209,7 +211,6 @@ export default function useSupabase() {
209211 category : "Supabase pull" ,
210212 level : "info" ,
211213 message : `Deleting ${ toDelete . length } local records absent on remote` ,
212- timestamp : Date . now ( ) ,
213214 } ) ;
214215
215216 await db
@@ -256,7 +257,6 @@ export default function useSupabase() {
256257 category : "Supabase delete" ,
257258 level : "info" ,
258259 message : `Deleting record with local_id: ${ localId } ` ,
259- timestamp : Date . now ( ) ,
260260 } ) ;
261261
262262 const { error } = await supabase
@@ -272,7 +272,6 @@ export default function useSupabase() {
272272 category : "Supabase delete" ,
273273 level : "info" ,
274274 message : `Successfully deleted record with local_id: ${ localId } ` ,
275- timestamp : Date . now ( ) ,
276275 } ) ;
277276 } catch ( e ) {
278277 console . log ( "Error deleting from Supabase:" , e ) ;
@@ -306,7 +305,6 @@ export default function useSupabase() {
306305 category : "Supabase login check" ,
307306 level : "info" ,
308307 message : `User has logged out of Supabase` ,
309- timestamp : Date . now ( ) ,
310308 } ) ;
311309 toast . success ( "Log out successful" , {
312310 description : "Search history will no longer be synced across devices." ,
@@ -323,7 +321,6 @@ export default function useSupabase() {
323321 category : "Google sign in" ,
324322 level : "info" ,
325323 message : `Play services available, attempting to sign in with Google` ,
326- timestamp : Date . now ( ) ,
327324 } ) ;
328325 setLoading ( true ) ;
329326 const response = await GoogleSignin . signIn ( ) ;
@@ -338,7 +335,6 @@ export default function useSupabase() {
338335 category : "Google sign in" ,
339336 level : "error" ,
340337 message : `Error caused by Supabase: ${ error . message } ` ,
341- timestamp : Date . now ( ) ,
342338 } ) ;
343339 throw { ...error , source : "supabase" } ;
344340 }
@@ -393,7 +389,6 @@ export default function useSupabase() {
393389 category : "Supabase login check" ,
394390 level : "info" ,
395391 message : `User is logged in with Supabase` ,
396- timestamp : Date . now ( ) ,
397392 } ) ;
398393 } else {
399394 isLoggedInRef . current = false ;
@@ -402,7 +397,6 @@ export default function useSupabase() {
402397 category : "Supabase login check" ,
403398 level : "info" ,
404399 message : `User is not logged in with Supabase` ,
405- timestamp : Date . now ( ) ,
406400 } ) ;
407401 }
408402 setLoading ( false ) ;
0 commit comments