Skip to content

Commit

Permalink
feat(editor): update parents' timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
thesophiaxu committed Mar 18, 2022
1 parent fcfe7ba commit 07bba56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/unigraph-dev-explorer/src/examples/notes/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const changesForOpenScopedMarkdownLink = (scope: ScopeForAutoComplete, ev: Keybo
};
};

const touchParents = (data: any) => {
const [parents] = getParentsAndReferences(data['~_value'], data['unigraph.origin']);
if (!data._hide) parents.push({ uid: data.uid });
window.unigraph.touch(parents.map((el) => el.uid));
};

export const useNoteEditor: (...args: any) => [any, (text: string) => void, () => string, () => void, any] = (
pullText: any,
pushText: any,
Expand Down Expand Up @@ -110,10 +116,8 @@ export const useNoteEditor: (...args: any) => [any, (text: string) => void, () =
}
const ret = oldTextRef.current === text && !isFlushing ? undefined : pushText(text, isFlushing);
oldTextRef.current = text;
if (ret) {
const [parents] = getParentsAndReferences(dataRef.current['~_value'], dataRef.current['unigraph.origin']);
if (!dataRef.current._hide) parents.push({ uid: dataRef.current.uid });
window.unigraph.touch(parents.map((el) => el.uid));
if (ret && !isFlushing) {
touchParents(dataRef.current);
}
return ret;
};
Expand Down Expand Up @@ -264,6 +268,7 @@ export const useNoteEditor: (...args: any) => [any, (text: string) => void, () =
callbacks.subsId,
parents,
);
touchParents(data);
window.unigraph.getState('global/searchPopup').setValue({ show: false });
},
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export const addChildren = (
!uidMode,
);
focusUid(myUid, false, -1);
window.unigraph.touch(parents.map((el) => el.uid));
};

export const splitChild = (data: any, context: NoteEditorContext, index: number, oldtext: string, at: number) => {
Expand Down

0 comments on commit 07bba56

Please sign in to comment.