Simplify loading logic to prevent empty state flashing when loading data in data providers
This commit is contained in:
parent
81e9f5b860
commit
a94682d645
|
@ -23,7 +23,6 @@ export const fetchTableData = async tableId => {
|
||||||
export const searchTable = async ({
|
export const searchTable = async ({
|
||||||
tableId,
|
tableId,
|
||||||
query,
|
query,
|
||||||
raw,
|
|
||||||
bookmark,
|
bookmark,
|
||||||
limit,
|
limit,
|
||||||
sort,
|
sort,
|
||||||
|
@ -31,14 +30,15 @@ export const searchTable = async ({
|
||||||
sortType,
|
sortType,
|
||||||
paginate,
|
paginate,
|
||||||
}) => {
|
}) => {
|
||||||
if (!tableId || (!query && !raw)) {
|
if (!tableId || !query) {
|
||||||
return
|
return {
|
||||||
|
rows: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const res = await API.post({
|
const res = await API.post({
|
||||||
url: `/api/search/${tableId}/rows`,
|
url: `/api/search/${tableId}/rows`,
|
||||||
body: {
|
body: {
|
||||||
query,
|
query,
|
||||||
raw,
|
|
||||||
bookmark,
|
bookmark,
|
||||||
limit,
|
limit,
|
||||||
sort,
|
sort,
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
sortType,
|
sortType,
|
||||||
paginate
|
paginate
|
||||||
) => {
|
) => {
|
||||||
console.log("FETCH")
|
|
||||||
loading = true
|
loading = true
|
||||||
if (dataSource?.type === "table") {
|
if (dataSource?.type === "table") {
|
||||||
const res = await API.searchTable({
|
const res = await API.searchTable({
|
||||||
|
@ -248,7 +247,7 @@
|
||||||
|
|
||||||
<div use:styleable={$component.styles} class="container">
|
<div use:styleable={$component.styles} class="container">
|
||||||
<Provider {actions} data={dataContext}>
|
<Provider {actions} data={dataContext}>
|
||||||
{#if !loaded && loading}
|
{#if !loaded}
|
||||||
<div class="loading">
|
<div class="loading">
|
||||||
<ProgressCircle />
|
<ProgressCircle />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue