-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1467: Port global setting consumer reads (→ getGlobalSetting) #821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,8 +34,6 @@ import getDiscourseNodes from "~/utils/getDiscourseNodes"; | |||||||||||||||
| import { OnloadArgs } from "roamjs-components/types"; | ||||||||||||||||
| import refreshConfigTree from "~/utils/refreshConfigTree"; | ||||||||||||||||
| import { render as renderGraphOverviewExport } from "~/components/ExportDiscourseContext"; | ||||||||||||||||
| import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid"; | ||||||||||||||||
| import { getSettingValueFromTree } from "roamjs-components/util"; | ||||||||||||||||
| import { | ||||||||||||||||
| getModifiersFromCombo, | ||||||||||||||||
| render as renderDiscourseNodeMenu, | ||||||||||||||||
|
|
@@ -52,15 +50,18 @@ import { renderNodeTagPopupButton } from "./renderNodeTagPopup"; | |||||||||||||||
| import { renderImageToolsMenu } from "./renderImageToolsMenu"; | ||||||||||||||||
| import { formatHexColor } from "~/components/settings/DiscourseNodeCanvasSettings"; | ||||||||||||||||
| import { mountLeftSidebar } from "~/components/LeftSidebarView"; | ||||||||||||||||
| import { getUidAndBooleanSetting } from "./getExportSettings"; | ||||||||||||||||
| import { getCleanTagText } from "~/components/settings/NodeConfig"; | ||||||||||||||||
| import getPleasingColors from "@repo/utils/getPleasingColors"; | ||||||||||||||||
| import { colord } from "colord"; | ||||||||||||||||
| import { renderPossibleDuplicates } from "~/components/VectorDuplicateMatches"; | ||||||||||||||||
| import getPageUidByPageTitle from "roamjs-components/queries/getPageUidByPageTitle"; | ||||||||||||||||
| import getPageTitleByPageUid from "roamjs-components/queries/getPageTitleByPageUid"; | ||||||||||||||||
| import findDiscourseNode from "./findDiscourseNode"; | ||||||||||||||||
| import { getPersonalSetting } from "~/components/settings/utils/accessors"; | ||||||||||||||||
| import { | ||||||||||||||||
| getPersonalSetting, | ||||||||||||||||
| getFeatureFlag, | ||||||||||||||||
| getGlobalSetting, | ||||||||||||||||
| } from "~/components/settings/utils/accessors"; | ||||||||||||||||
|
|
||||||||||||||||
| const debounce = (fn: () => void, delay = 250) => { | ||||||||||||||||
| let timeout: number; | ||||||||||||||||
|
|
@@ -105,12 +106,7 @@ export const initObservers = async ({ | |||||||||||||||
| const { title, uid } = getTitleAndUidFromHeader(h1); | ||||||||||||||||
| const props = { title, h1, onloadArgs }; | ||||||||||||||||
|
|
||||||||||||||||
| const isSuggestiveModeEnabled = getUidAndBooleanSetting({ | ||||||||||||||||
| tree: getBasicTreeByParentUid( | ||||||||||||||||
| getPageUidByPageTitle(DISCOURSE_CONFIG_PAGE_TITLE), | ||||||||||||||||
| ), | ||||||||||||||||
| text: "(BETA) Suggestive Mode Enabled", | ||||||||||||||||
| }).value; | ||||||||||||||||
| const isSuggestiveModeEnabled = getFeatureFlag("Suggestive mode enabled"); | ||||||||||||||||
|
|
||||||||||||||||
| const node = findDiscourseNode({ uid, title }); | ||||||||||||||||
| const isDiscourseNode = node && node.backedBy !== "default"; | ||||||||||||||||
|
|
@@ -256,12 +252,7 @@ export const initObservers = async ({ | |||||||||||||||
| } | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| const configTree = getBasicTreeByParentUid(configPageUid); | ||||||||||||||||
| const globalTrigger = getSettingValueFromTree({ | ||||||||||||||||
| tree: configTree, | ||||||||||||||||
| key: "trigger", | ||||||||||||||||
| defaultValue: "\\", | ||||||||||||||||
| }).trim(); | ||||||||||||||||
| const globalTrigger = (getGlobalSetting<string>(["Trigger"]) ?? "\\").trim(); | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 255 sits in the synchronous body of This is the same root cause as the 🛡️ Proposed fix- const globalTrigger = (getGlobalSetting<string>(["Trigger"]) ?? "\\").trim();
+ let globalTrigger: string;
+ try {
+ globalTrigger = (getGlobalSetting<string>(["Trigger"]) ?? "\\").trim();
+ } catch {
+ globalTrigger = "\\";
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats the goal to figure out bugs explicitly this pr and the project is under testing so it makes sense for this phase of the project
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Feel free to ping me if you'd like help cataloging or triaging any of the exceptions that come up during testing. Good luck with the migration! 🚀 🧠 Learnings used |
||||||||||||||||
| const personalTriggerCombo = getPersonalSetting<IKeyCombo>([ | ||||||||||||||||
| "Personal node menu trigger", | ||||||||||||||||
| ]); | ||||||||||||||||
|
|
@@ -276,10 +267,7 @@ export const initObservers = async ({ | |||||||||||||||
| className: "starred-pages-wrapper", | ||||||||||||||||
| callback: (el) => { | ||||||||||||||||
| void (async () => { | ||||||||||||||||
| const isLeftSidebarEnabled = getUidAndBooleanSetting({ | ||||||||||||||||
| tree: configTree, | ||||||||||||||||
| text: "(BETA) Left Sidebar", | ||||||||||||||||
| }).value; | ||||||||||||||||
| const isLeftSidebarEnabled = getFeatureFlag("Enable left sidebar"); | ||||||||||||||||
| const container = el as HTMLDivElement; | ||||||||||||||||
| if (isLeftSidebarEnabled) { | ||||||||||||||||
| container.style.padding = "0"; | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,10 @@ | ||||||||||||||||||||||||
| import { DEFAULT_CANVAS_PAGE_FORMAT } from ".."; | ||||||||||||||||||||||||
| import { getFormattedConfigTree } from "./discourseConfigRef"; | ||||||||||||||||||||||||
| import { getGlobalSetting } from "~/components/settings/utils/accessors"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export const isCanvasPage = ({ title }: { title: string }) => { | ||||||||||||||||||||||||
| const { canvasPageFormat } = getFormattedConfigTree(); | ||||||||||||||||||||||||
| const format = canvasPageFormat.value || DEFAULT_CANVAS_PAGE_FORMAT; | ||||||||||||||||||||||||
| const format = | ||||||||||||||||||||||||
| getGlobalSetting<string>(["Canvas page format"]) || | ||||||||||||||||||||||||
| DEFAULT_CANVAS_PAGE_FORMAT; | ||||||||||||||||||||||||
|
Comment on lines
+5
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When
🛡️ Proposed fix — wrap in try/catch to honour the intended fallback- const format =
- getGlobalSetting<string>(["Canvas page format"]) ||
- DEFAULT_CANVAS_PAGE_FORMAT;
+ let format: string;
+ try {
+ format =
+ getGlobalSetting<string>(["Canvas page format"]) ||
+ DEFAULT_CANVAS_PAGE_FORMAT;
+ } catch {
+ format = DEFAULT_CANVAS_PAGE_FORMAT;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats the goal to figure out bugs explicitly this pr and the project is under testing so it makes sense for this phase of the project
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🧠 Learnings used |
||||||||||||||||||||||||
| const canvasRegex = new RegExp(`^${format}$`.replace(/\*/g, ".+")); | ||||||||||||||||||||||||
| return canvasRegex.test(title); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.