Skip to content

Commit

Permalink
Sparql query fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dvargas92495 committed Dec 23, 2022
1 parent 169a334 commit db7604c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/sparql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import apiGet from "roamjs-components/util/apiGet";
import extractTag from "roamjs-components/util/extractTag";
import renderOverlay from "roamjs-components/util/renderOverlay";
import addStyle from "roamjs-components/dom/addStyle";
import getFirstChildUidByBlockUid from "roamjs-components/queries/getFirstChildUidByBlockUid";

// https://github.com/spamscanner/url-regex-safe/blob/master/src/index.js
const protocol = `(?:https?://)`;
Expand All @@ -72,7 +73,7 @@ export type RenderProps = {
};
};
parentUid: string;
location: { "window-id": string; "block-uid": string };
blockUid: string;
};

export const DEFAULT_EXPORT_LABEL = "SPARQL Import";
Expand Down Expand Up @@ -275,7 +276,7 @@ const SparqlQuery = ({
onClose,
queriesCache,
parentUid,
location,
blockUid: _blockUid,
}: {
onClose: () => void;
} & RenderProps): React.ReactElement => {
Expand All @@ -286,8 +287,8 @@ const SparqlQuery = ({
[parentUid]
);
const cursorBlockUid = useMemo(
() => (getTextByBlockUid(parentUid) ? parentUid : location["block-uid"]),
[parentUid]
() => (getTextByBlockUid(parentUid) ? parentUid : _blockUid),
[parentUid, _blockUid]
);
const cursorBlockString = useMemo(
() => extractTag(getTextByBlockUid(cursorBlockUid)),
Expand Down Expand Up @@ -738,7 +739,9 @@ const initializeSparql = () => {
.getOpenPageOrBlockUid()
.then((parentUid) =>
render({
location: window.roamAlphaAPI.ui.getFocusedBlock(),
blockUid:
window.roamAlphaAPI.ui.getFocusedBlock()?.["block-uid"] ||
getFirstChildUidByBlockUid(parentUid),
queriesCache,
parentUid,
})
Expand Down

0 comments on commit db7604c

Please sign in to comment.