Skip to content

Commit

Permalink
fix(dynamic view): add option to ignore backlink completely and use p…
Browse files Browse the repository at this point in the history
…arents' backlinks
  • Loading branch information
thesophiaxu committed Mar 24, 2022
1 parent cb036bd commit d9e6da7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function AutoDynamicView({
if (!callbacks) callbacks = {};

const shouldGetBacklinks =
finalOptions.shouldGetBacklinks || (!excludableTypes.includes(object?.type?.['unigraph.id']) && !inline);
!finalOptions.ignoreBacklinks &&
(finalOptions.shouldGetBacklinks || (!excludableTypes.includes(object?.type?.['unigraph.id']) && !inline));

const dataContext = React.useContext(DataContext);
const tabContext = React.useContext(TabContext);
Expand Down Expand Up @@ -303,7 +304,7 @@ export function AutoDynamicView({
<DataContextWrapper
contextUid={object?.uid}
contextData={getObjectRef.current()}
parents={totalParents}
parents={finalOptions.ignoreBacklinks ? dataContext.parents : totalParents}
viewType="$/schema/dynamic_view"
expandedChildren={expandedChildren || false}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const childrenComponents = {
'$/schema/embed_block': {
view: DetailedEmbedBlock,
query: noteQuery,
options: {
ignoreBacklinks: true,
},
},
};

Expand Down Expand Up @@ -832,7 +835,7 @@ export function DetailedEmbedBlock({
console.log(ev.target);
const caretPos = Number((ev.target as HTMLElement).getAttribute('markdownPos') || -1);
(ev.target as HTMLElement).removeAttribute('markdownPos');
const finalCaretPos = caretPos === -1 ? getCurrentText().length : caretPos;
const finalCaretPos = caretPos === -1 ? getCurrentText?.()?.length : caretPos;
window.unigraph.getState('global/focused').setValue({
...window.unigraph.getState('global/focused').value,
uid: data?.uid,
Expand Down

0 comments on commit d9e6da7

Please sign in to comment.