Skip to content

Commit 7a44b37

Browse files
committed
remove loadInBackground. Also fix a lint error
1 parent 10f3d50 commit 7a44b37

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

apps/roam/src/components/QueryBuilder.tsx

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -65,44 +65,41 @@ const QueryBuilder = ({ pageUid, isEditBlock, showAlias }: Props) => {
6565
const [columns, setColumns] = useState<Column[]>([]);
6666
const [results, setResults] = useState<Result[]>([]);
6767
const containerRef = useRef<HTMLDivElement>(null);
68-
const onRefresh = useCallback(
69-
(loadInBackground = false) => {
70-
setError("");
71-
setLoading(!loadInBackground);
72-
const args = parseQuery(pageUid);
73-
const { inputs } = parseResultSettings(pageUid, args.columns);
74-
const transformedInputs = Object.fromEntries(
75-
inputs.map(({ key, inputValue }) => [key, inputValue]),
76-
);
77-
setTimeout(() => {
78-
fireQuery({ ...args, inputs: transformedInputs })
79-
.then((results) => {
80-
setColumns(args.columns);
81-
setResults(results);
82-
})
83-
.catch(() => {
84-
setError(
85-
`Query failed to run. Try running a new query from the editor.`,
86-
);
87-
})
88-
.finally(() => {
89-
const tree = getBasicTreeByParentUid(pageUid);
90-
const node = getSubTree({ tree, key: "results" });
91-
return (
92-
node.uid
93-
? Promise.resolve(node.uid)
94-
: createBlock({
95-
parentUid: pageUid,
96-
node: { text: "results" },
97-
})
98-
).then(() => {
99-
setLoading(false);
100-
});
68+
const onRefresh = useCallback(() => {
69+
setError("");
70+
setLoading(true);
71+
const args = parseQuery(pageUid);
72+
const { inputs } = parseResultSettings(pageUid, args.columns);
73+
const transformedInputs = Object.fromEntries(
74+
inputs.map(({ key, inputValue }) => [key, inputValue]),
75+
);
76+
setTimeout(() => {
77+
fireQuery({ ...args, inputs: transformedInputs })
78+
.then((results) => {
79+
setColumns(args.columns);
80+
setResults(results);
81+
})
82+
.catch(() => {
83+
setError(
84+
`Query failed to run. Try running a new query from the editor.`,
85+
);
86+
})
87+
.finally(() => {
88+
const tree = getBasicTreeByParentUid(pageUid);
89+
const node = getSubTree({ tree, key: "results" });
90+
void (
91+
node.uid
92+
? Promise.resolve(node.uid)
93+
: createBlock({
94+
parentUid: pageUid,
95+
node: { text: "results" },
96+
})
97+
).then(() => {
98+
setLoading(false);
10199
});
102-
}, 1);
103-
},
104-
[setResults, pageUid, setLoading, setColumns],
105-
);
100+
});
101+
}, 1);
102+
}, [setResults, pageUid, setLoading, setColumns]);
106103
useEffect(() => {
107104
if (!isEdit) {
108105
if (hasResults) {

0 commit comments

Comments
 (0)