Skip to content

Commit 2477fe7

Browse files
authored
Attribute Select - use backend.q to get attributes (#496)
* use backend.q * 1.6.2
1 parent 2f33b0f commit 2477fe7

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@types/mozilla-readability": "^0.2.0",
2424
"@types/turndown": "^5.0.1"
2525
},
26-
"version": "1.6.1",
26+
"version": "1.6.2",
2727
"samepage": {
2828
"extends": "node_modules/roamjs-components/package.json"
2929
}

src/features/attributeSelect.tsx

+17-16
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,22 @@ const AttributeConfigPanel = ({
286286
}, [configUid]);
287287
const [attributesInGraph, setAttributesInGraph] = useState<string[]>([]);
288288
const [noAttributesInGraph, setNoAttributesInGraph] = useState(false);
289-
const getAttributesInGraph = () => {
290-
const attributesInGraph = (
291-
window.roamAlphaAPI.data.fast.q(
289+
const getAttributesInGraph = async () => {
290+
const results =
291+
// @ts-ignore
292+
(await window.roamAlphaAPI.data.backend.q(
292293
`[:find
293-
(pull ?page [:node/title])
294-
:where
295-
[?b :attrs/lookup _]
296-
[?b :entity/attrs ?a]
297-
[(untuple ?a) [[?c ?d]]]
298-
[(get ?d :value) ?s]
299-
[(untuple ?s) [?e ?uid]]
300-
[?page :block/uid ?uid]
301-
]`
302-
) as [PullBlock][]
303-
).map((p) => p[0]?.[":node/title"] || "");
294+
(pull ?page [:node/title])
295+
:where
296+
[?b :attrs/lookup _]
297+
[?b :entity/attrs ?a]
298+
[(untuple ?a) [[?c ?d]]]
299+
[(get ?d :value) ?s]
300+
[(untuple ?s) [?e ?uid]]
301+
[?page :block/uid ?uid]
302+
]`
303+
)) as [PullBlock][];
304+
const attributesInGraph = results.map((p) => p[0]?.[":node/title"] || "");
304305
if (attributesInGraph.length === 0) {
305306
setNoAttributesInGraph(true);
306307
} else {
@@ -389,8 +390,8 @@ const AttributeConfigPanel = ({
389390
loading={isLoading}
390391
onClick={() => {
391392
setIsLoading(true);
392-
setTimeout(() => {
393-
getAttributesInGraph();
393+
setTimeout(async () => {
394+
await getAttributesInGraph();
394395

395396
setIsLoading(false);
396397
focusAndOpenSelect();

0 commit comments

Comments
 (0)