-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1291: Port discourse node specification #765
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 |
|---|---|---|
|
|
@@ -74,7 +74,13 @@ const initializeSettingsBlockProps = ( | |
| const uid = blockMap[key]; | ||
| if (uid) { | ||
| const existingProps = getBlockProps(uid); | ||
| if (!existingProps || Object.keys(existingProps).length === 0) { | ||
| // TODO: Overwriting on safeParse failure is a temporary fix for schema shape changes | ||
| // (e.g. specification: [] -> {enabled, query}). Replace with proper versioned migrations. | ||
|
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. Why do we need this already if this is our first version? As in, we don't have any other versions/migrations?
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. we already have merged code in main that would have created the previous specification structure in graphs that have main version of roam plugin and so we need to migrate for those graphs. |
||
| if ( | ||
| !existingProps || | ||
| Object.keys(existingProps).length === 0 || | ||
| !schema.safeParse(existingProps).success | ||
| ) { | ||
| const defaults = schema.parse({}); | ||
| setBlockProps(uid, defaults, false); | ||
| } | ||
|
|
@@ -108,7 +114,12 @@ const initSingleDiscourseNode = async ( | |
| ); | ||
| const existingProps = getBlockProps(pageUid); | ||
|
|
||
| if (!existingProps || Object.keys(existingProps).length === 0) { | ||
| // TODO: Same temporary fix as initializeSettingsBlockProps — replace with proper migrations. | ||
| if ( | ||
| !existingProps || | ||
| Object.keys(existingProps).length === 0 || | ||
| !DiscourseNodeSchema.safeParse(existingProps).success | ||
| ) { | ||
| const nodeData = DiscourseNodeSchema.parse({ | ||
| text: node.text, | ||
| type: node.type, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to resort to this disable? What did you try to properly fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not under scope of this pr every other key also has the same problem and in multiple places in the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing it properly would result in more touch points and get out of scope for this pr