@@ -42,8 +42,6 @@ export default function StacGeoparquetProvider({
4242
4343 useEffect ( ( ) => {
4444 if ( state . path ) {
45- dispatch ( { type : "set-id" } ) ;
46- dispatch ( { type : "set-item" } ) ;
4745 if ( connection ) {
4846 ( async ( ) => {
4947 let result ;
@@ -129,9 +127,8 @@ export default function StacGeoparquetProvider({
129127 }
130128 } , [ state . path , connection , dispatch ] ) ;
131129
132- // TODO I don't like this depending on state.path.
133130 useEffect ( ( ) => {
134- if ( state . id ) {
131+ if ( state . id && state . path ) {
135132 if ( connection ) {
136133 ( async ( ) => {
137134 // TODO refactor query so we don't repeat logic.
@@ -144,8 +141,6 @@ export default function StacGeoparquetProvider({
144141 } else {
145142 // TODO Handle missing connection
146143 }
147- } else {
148- dispatch ( { type : "set-item" } ) ;
149144 }
150145 } , [ state . id , state . path , connection , dispatch ] ) ;
151146
@@ -159,13 +154,13 @@ export default function StacGeoparquetProvider({
159154function reducer ( state : StacGeoparquetState , action : StacGeoparquetAction ) {
160155 switch ( action . type ) {
161156 case "set-path" :
162- return { ...state , path : action . path } ;
157+ return { ...state , path : action . path , id : undefined , item : undefined } ;
163158 case "set-metadata" :
164159 return { ...state , metadata : action . metadata } ;
165160 case "set-table" :
166161 return { ...state , table : action . table } ;
167162 case "set-id" :
168- return { ...state , id : action . id } ;
163+ return { ...state , id : action . id , item : undefined } ;
169164 case "set-item" :
170165 return { ...state , item : action . item } ;
171166 }
0 commit comments