Skip to content

Commit 1bbe43e

Browse files
authored
ENG-1279 Discourse Context Overlay doesn't update number (#693)
* eng-1279 refreshing the discourse context should also refresh the overlay
1 parent 16bb761 commit 1bbe43e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

apps/roam/src/components/DiscourseContext.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type DiscourseContextResults = Awaited<
3131
type Props = {
3232
uid: string;
3333
results?: DiscourseContextResults;
34+
overlayRefresh?: () => void;
3435
};
3536

3637
const ExtraColumnRow = (r: Result) => {
@@ -279,7 +280,7 @@ const ContextTab = ({
279280
<CreateRelationButton
280281
sourceNodeUid={parentUid}
281282
onClose={() => {
282-
window.setTimeout(onRefresh, 250);
283+
window.setTimeout(onRefresh, 450, true);
283284
}}
284285
/>
285286
<Switch
@@ -316,7 +317,7 @@ const ContextTab = ({
316317
);
317318
};
318319

319-
export const ContextContent = ({ uid, results }: Props) => {
320+
export const ContextContent = ({ uid, results, overlayRefresh }: Props) => {
320321
const [rawQueryResults, setRawQueryResults] = useState<
321322
Record<string, DiscourseContextResults[number]>
322323
>({});
@@ -350,13 +351,16 @@ export const ContextContent = ({ uid, results }: Props) => {
350351
uid,
351352
onResult: addLabels,
352353
ignoreCache,
353-
}).finally(() => setLoading(false));
354+
}).finally(() => {
355+
if (overlayRefresh) overlayRefresh();
356+
setLoading(false);
357+
});
354358
},
355-
[uid, setRawQueryResults, setLoading, addLabels],
359+
[uid, setRawQueryResults, setLoading, addLabels, overlayRefresh],
356360
);
357361

358362
const delayedRefresh = () => {
359-
window.setTimeout(onRefresh, 250);
363+
window.setTimeout(onRefresh, 450, true);
360364
};
361365

362366
useEffect(() => {

apps/roam/src/components/DiscourseContextOverlay.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ const DiscourseContextOverlay = ({
148148
results.length === 0 ? "flex items-center justify-center" : ""
149149
}`}
150150
>
151-
<ContextContent uid={tagUid} results={results} />
151+
<ContextContent
152+
uid={tagUid}
153+
results={results}
154+
overlayRefresh={refresh}
155+
/>
152156
</div>
153157
}
154158
target={

apps/roam/src/components/results-view/ResultsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ const ResultRow = ({
350350
content: "Relation deleted",
351351
intent: "success",
352352
});
353-
onRefresh();
353+
onRefresh(true);
354354
})
355355
.catch((e) => {
356356
// this one should be an internalError

0 commit comments

Comments
 (0)