Skip to content

Commit efcb1d6

Browse files
committed
ENG-1819: Skip fold marker persistence when user uid is unavailable
Review follow-up: roamAlphaAPI.user.uid() is typed string | null. With no uid the fold toggle is now session-only instead of reading/writing a marker block that every uid-less user would share.
1 parent c031c3c commit efcb1d6

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

apps/roam/src/components/LeftSidebarView.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -638,23 +638,24 @@ const GlobalSection = ({
638638
try {
639639
const nextIsOpen = !isOpen;
640640
setIsOpen(nextIsOpen);
641-
const markerText = getGlobalSectionFoldedMarkerText(
642-
window.roamAlphaAPI.user.uid() || "",
643-
);
644-
if (nextIsOpen) {
645-
const children = getBasicTreeByParentUid(leftSidebarUid);
646-
await Promise.all(
647-
children
648-
.filter((c) => c.text === markerText)
649-
.map((c) => deleteBlock(c.uid)),
650-
);
651-
} else {
652-
await createBlock({
653-
parentUid: leftSidebarUid,
654-
node: { text: markerText },
655-
});
641+
const userUid = window.roamAlphaAPI.user.uid();
642+
if (userUid) {
643+
const markerText = getGlobalSectionFoldedMarkerText(userUid);
644+
if (nextIsOpen) {
645+
const children = getBasicTreeByParentUid(leftSidebarUid);
646+
await Promise.all(
647+
children
648+
.filter((c) => c.text === markerText)
649+
.map((c) => deleteBlock(c.uid)),
650+
);
651+
} else {
652+
await createBlock({
653+
parentUid: leftSidebarUid,
654+
node: { text: markerText },
655+
});
656+
}
657+
refreshConfigTree();
656658
}
657-
refreshConfigTree();
658659
setPersonalSetting([PERSONAL_KEYS.globalSectionFolded], !nextIsOpen);
659660
} finally {
660661
isTogglingRef.current = false;

apps/roam/src/utils/getLeftSidebarSettings.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,13 @@ export const getLeftSidebarSettings = (
317317
tree: leftSidebarChildren,
318318
text: "Sidebar Migrated",
319319
});
320-
const globalSectionFolded = getUidAndBooleanSetting({
321-
tree: leftSidebarChildren,
322-
text: getGlobalSectionFoldedMarkerText(
323-
window.roamAlphaAPI.user.uid() || "",
324-
),
325-
});
320+
const currentUserUid = window.roamAlphaAPI.user.uid();
321+
const globalSectionFolded: BooleanSetting = currentUserUid
322+
? getUidAndBooleanSetting({
323+
tree: leftSidebarChildren,
324+
text: getGlobalSectionFoldedMarkerText(currentUserUid),
325+
})
326+
: { uid: undefined, value: false };
326327
return {
327328
uid: leftSidebarUid,
328329
favoritesMigrated,

0 commit comments

Comments
 (0)