Fix types

This commit is contained in:
Adria Navarro 2025-01-07 13:42:51 +01:00
parent 91300c54e9
commit bf02515ff0
2 changed files with 11 additions and 7 deletions

View File

@ -10,9 +10,10 @@ import {
import { tick } from "svelte" import { tick } from "svelte"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { sleep } from "../../../utils/utils" import { sleep } from "../../../utils/utils"
import { FieldType, Row, UIFetchAPI, UIRow } from "@budibase/types" import { FieldType, Row, UIRow } from "@budibase/types"
import { getRelatedTableValues } from "../../../utils" import { getRelatedTableValues } from "../../../utils"
import { Store as StoreContext } from "." import { Store as StoreContext } from "."
import DataFetch from "../../../fetch/DataFetch"
interface IndexedUIRow extends UIRow { interface IndexedUIRow extends UIRow {
__idx: number __idx: number
@ -20,7 +21,7 @@ interface IndexedUIRow extends UIRow {
interface RowStore { interface RowStore {
rows: Writable<UIRow[]> rows: Writable<UIRow[]>
fetch: Writable<UIFetchAPI | null> fetch: Writable<DataFetch<any, any, any> | null>
loaded: Writable<boolean> loaded: Writable<boolean>
refreshing: Writable<boolean> refreshing: Writable<boolean>
loading: Writable<boolean> loading: Writable<boolean>
@ -225,7 +226,7 @@ export const createActions = (context: StoreContext): RowActionStore => {
}) })
// Subscribe to changes of this fetch model // Subscribe to changes of this fetch model
unsubscribe = newFetch.subscribe(async ($fetch: UIFetchAPI) => { unsubscribe = newFetch.subscribe(async $fetch => {
if ($fetch.error) { if ($fetch.error) {
// Present a helpful error to the user // Present a helpful error to the user
let message = "An unknown error occurred" let message = "An unknown error occurred"

View File

@ -26,8 +26,11 @@ interface DataFetchStore<TDefinition, TQuery> {
pageNumber: number pageNumber: number
cursor: null cursor: null
cursors: any[] cursors: any[]
resetKey: number resetKey: string
error: null error: {
message: string
status: number
} | null
definition?: TDefinition | null definition?: TDefinition | null
} }
@ -132,7 +135,7 @@ export default abstract class DataFetch<
pageNumber: 0, pageNumber: 0,
cursor: null, cursor: null,
cursors: [], cursors: [],
resetKey: Math.random(), resetKey: Math.random().toString(),
error: null, error: null,
}) })
@ -284,7 +287,7 @@ export default abstract class DataFetch<
info: page.info, info: page.info,
cursors: paginate && page.hasNextPage ? [null, page.cursor] : [null], cursors: paginate && page.hasNextPage ? [null, page.cursor] : [null],
error: page.error, error: page.error,
resetKey: Math.random(), resetKey: Math.random().toString(),
})) }))
} }