@@ -55,28 +55,18 @@ export async function connectToFirebase(model) {
5555 // setting missing
5656 // also save filters to local storage
5757 //
58- const options = JSON . parse ( localStorage . getItem ( "filterOptions" ) ) ;
59- if ( options ) {
60- model . setFilterOptions ( options ) ;
61- }
62- if ( ! model ?. currentSearchText ) {
63- const search = localStorage . getItem ( "search" ) ;
64- if ( search ) {
65- model . setCurrentSearchText ( search ) ;
66- }
58+ // we dont restore for the expo...
59+ //
60+ // const options = JSON.parse(localStorage.getItem("filterOptions") );
61+ // if (options) {
62+ // model.setFilterOptions(options);
63+ // }
64+ const search = localStorage . getItem ( " search" ) ;
65+ if ( search ) {
66+ model . setCurrentSearchText ( search ) ;
6767 }
6868
6969 // automaticaly save filter and search to local storage whenever they change
70- reaction (
71- ( ) => ( {
72- filterOptions : JSON . stringify ( model . filterOptions ) ,
73- search : model . currentSearchText ,
74- } ) ,
75- ( { filterOptions, search } ) => {
76- localStorage . setItem ( "filterOptions" , filterOptions ) ;
77- localStorage . setItem ( "search" , search ) ;
78- }
79- ) ;
8070 /**
8171 * Hook to start synchronization when user is authenticated.
8272 */
@@ -91,6 +81,16 @@ export async function connectToFirebase(model) {
9181 model . setReady ( ) ;
9282 }
9383 } ) ;
84+ reaction (
85+ ( ) => ( {
86+ filterOptions : JSON . stringify ( model . filterOptions ) ,
87+ search : model . currentSearchText ,
88+ } ) ,
89+ ( { filterOptions, search } ) => {
90+ localStorage . setItem ( "filterOptions" , filterOptions ) ;
91+ localStorage . setItem ( "search" , search ) ;
92+ }
93+ ) ;
9494}
9595
9696// fetches all relevant information to create the model
@@ -104,8 +104,8 @@ async function firebaseToModel(model) {
104104 await runTransaction ( userRef , ( currentData ) => {
105105 if ( currentData ) {
106106 if ( data ?. favourites ) model . setFavourite ( data . favourites ) ;
107- if ( data ?. currentSearchText )
108- model . setCurrentSearchText ( data . currentSearchText ) ;
107+ // if (data?.currentSearchText)
108+ // model.setCurrentSearchText(data.currentSearchText);
109109 // Add other fields as needed
110110 }
111111 return currentData ; // Return the current data to avoid overwriting
@@ -123,7 +123,7 @@ export function syncModelToFirebase(model) {
123123 ( ) => ( {
124124 userId : model ?. user . uid ,
125125 favourites : toJS ( model . favourites ) ,
126- currentSearchText : toJS ( model . currentSearchText ) ,
126+ // currentSearchText: toJS(model.currentSearchText),
127127 } ) ,
128128 async ( { userId, favourites, currentSearchText } ) => {
129129 if ( ! userId ) return ;
@@ -134,7 +134,7 @@ export function syncModelToFirebase(model) {
134134 return {
135135 ...currentData ,
136136 favourites,
137- currentSearchText,
137+ // currentSearchText,
138138 } ;
139139 } ) . catch ( ( error ) => {
140140 console . error ( "Error syncing model to Firebase:" , error ) ;
0 commit comments