MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / fetchItems

Function fetchItems

pkg/webui/containers/fetch-table/index.js:148–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146
147 useEffect(() => {
148 const fetchItems = async () => {
149 setFetching(true)
150 const f = { query: debouncedQuery || '', page, limit: globalPageSize ?? pageSize }
151 if (tabs.find(t => t.name === queryTab)) {
152 f.tab = queryTab
153 } else {
154 setQueryTab(defaultTab)
155 f.tab = undefined
156 }
157
158 if (orderValidator(order)) {
159 f.order = order
160 } else {
161 if (isMounted.current) {
162 setOrder(defaultOrder)
163 }
164 f.order = defaultOrder
165 }
166
167 try {
168 if (f.query && searchItemsAction) {
169 await dispatch(attachPromise(searchItemsAction(f)))
170 } else {
171 await dispatch(attachPromise(getItemsAction(f)))
172 setTab(f.tab)
173 }
174 if (isMounted.current) {
175 setFetching(false)
176 setInitialFetch(false)
177 }
178 } catch (error) {
179 if (isMounted.current) {
180 setError(error)
181 setFetching(false)
182 }
183 }
184 }
185 fetchItems()
186 }, [
187 debouncedQuery,

Callers 1

index.jsFile · 0.85

Calls 1

orderValidatorFunction · 0.85

Tested by

no test coverage detected