Skip to content

Commit d6ee840

Browse files
authored
ENG-1411: Remove secondary cache on getOverlayInfo (#886)
1 parent 8401c57 commit d6ee840

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

apps/roam/src/components/DiscourseContextOverlay.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import ReactDOM from "react-dom";
1111
import { ContextContent } from "./DiscourseContext";
1212
import useInViewport from "react-in-viewport/dist/es/lib/useInViewport";
1313
import normalizePageTitle from "roamjs-components/queries/normalizePageTitle";
14+
import { USE_REIFIED_RELATIONS } from "~/data/userSettings";
15+
import { getSetting } from "~/utils/extensionSettings";
1416
import deriveDiscourseNodeAttribute from "~/utils/deriveDiscourseNodeAttribute";
1517
import getSettingValueFromTree from "roamjs-components/util/getSettingValueFromTree";
1618
import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid";
@@ -31,18 +33,11 @@ type DiscourseData = {
3133
refs: number;
3234
};
3335

34-
const cache: {
35-
[tag: string]: DiscourseData;
36-
} = {};
37-
3836
const getOverlayInfo = async (
3937
tag: string,
4038
ignoreCache?: boolean,
4139
): Promise<DiscourseData> => {
4240
try {
43-
if (ignoreCache) delete cache[tag];
44-
if (cache[tag]) return cache[tag];
45-
4641
const relations = getDiscourseRelations();
4742
const nodes = getDiscourseNodes(relations);
4843

@@ -58,10 +53,10 @@ const getOverlayInfo = async (
5853
),
5954
]);
6055

61-
return (cache[tag] = {
56+
return {
6257
results,
6358
refs: refs.length,
64-
});
59+
};
6560
} catch (error) {
6661
console.error(`Error getting overlay info for ${tag}:`, error);
6762
return {
@@ -226,6 +221,8 @@ const useDiscourseContext = (uid: string, tag: string) => {
226221
uid,
227222
score,
228223
numResults,
224+
ignoreCache,
225+
reified: getSetting<boolean>(USE_REIFIED_RELATIONS),
229226
},
230227
});
231228
}

0 commit comments

Comments
 (0)