-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(dashboard): in-app editor preview only call when tab is opened #7186
Conversation
}, [editorValue]); | ||
|
||
const previewResult = previewData?.result; | ||
const preview = previewResult?.preview as InAppRenderOutput | undefined; |
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.
I don't like this, but unfortunately, with the current implementation, we can't show the skeleton loader optimistically.
To have the types automatically picked we need to do check for the type:
if (previewData?.result?.type !== IN_APP) {
// RENDER SKELETON
}
// RENDER IN_APP PREVIEW
This requires a lot of refactoring in this file.
const dataRef = useDataRef({ | ||
workflowSlug, | ||
stepSlug, | ||
controlValues, | ||
editorValue, | ||
}); | ||
|
||
useEffect(() => { | ||
previewStep({ | ||
workflowSlug: dataRef.current.workflowSlug, | ||
stepSlug: dataRef.current.stepSlug, | ||
data: { controlValues: dataRef.current.controlValues, previewPayload: JSON.parse(dataRef.current.editorValue) }, | ||
}); | ||
}, [dataRef, previewStep]); |
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.
on mount call the preview endpoint
const previewStepCallback = useCallback(() => { | ||
return previewStep({ | ||
workflowSlug, | ||
stepSlug, | ||
data: { controlValues, previewPayload: JSON.parse(editorValue) }, | ||
}); | ||
}, [workflowSlug, stepSlug, controlValues, editorValue, previewStep]); |
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.
used for the apply button click
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for novu-stg-vite-dashboard-poc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
apps/dashboard/src/components/workflow-editor/steps/use-editor-preview.tsx
Outdated
Show resolved
Hide resolved
<div className="to-background absolute -bottom-3 h-16 w-full bg-gradient-to-b from-transparent to-80%" /> | ||
</div> | ||
|
||
<InboxPreview isPreviewPending={isPreviewPending} previewData={previewData} /> | ||
<Accordion type="single" collapsible value={accordionValue} onValueChange={setAccordionValue}> |
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.
I didn't decide on removing the accordion here in case of API "graceful error" as it provides a weird user experience when the components is shown during the loading state and then disappears.
if (!isPreviewPending && !data?.result) { | ||
return null; | ||
const previewResult = previewData?.result; | ||
if (isPreviewPending || previewData === undefined) { |
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.
the preview endpoint should never respond with an error
What changed? Why was the change needed?
In-App Editor Preview - the api request for the preview should only be called when the tab is opened or when the
apply
button is pressed.In the attached video, there are 2x calls to the API because the React
effect
is called twice on the mount.Screenshots
Screen.Recording.2024-12-02.at.23.42.05.mov
Screen.Recording.2024-12-02.at.23.34.56.mov
Screen.Recording.2024-12-02.at.23.02.44.mov
Screen.Recording.2024-12-02.at.23.00.38.mov