-
Notifications
You must be signed in to change notification settings - Fork 21
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
Skip dispatching messages if Turbo is not loaded #77
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -1600,6 +1600,10 @@ var HotwireSpark = (function () { | |
document.body.setAttribute("data-hotwire-spark-ready", ""); | ||
}, | ||
async received(message) { | ||
if (!window.Turbo) { | ||
log(`Turbo not detected, skipping ${message.action}`); | ||
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. I think Turbo is only required if you're using the |
||
return; | ||
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. This would hide errors for apps without Turbo and silently not update the page by default. I think a better approach here would be to always log a descriptive error with an explanation on how to avoid the error, e.g. |
||
} | ||
try { | ||
await this.dispatch(message); | ||
} catch (error) { | ||
|
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.
You have edited the build output of rollup instead of the original source files. To properly adapt your patch you should add your changes to the original
monitoring_channel.js
async received()
method and runnpm run build
to compile the files. Your patch should contain all changes (the build output and your original changes).