-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
PostMessage without serialization #903
PostMessage without serialization #903
Conversation
Codecov Report
@@ Coverage Diff @@
## master #903 +/- ##
=======================================
Coverage 43.98% 43.99%
=======================================
Files 127 127
Lines 2903 2905 +2
Branches 662 656 -6
=======================================
+ Hits 1277 1278 +1
- Misses 1613 1614 +1
Partials 13 13
Continue to review full report at Codecov.
|
Yes, it's a good point, but for example, in dev, webpack could send string inside post message data. |
I'm not very good in typescript and I can't catch how to make it.
In this line JSON.parse implicitly changing type to any and in next line we can get data.theme. If I remove JSON.parse data type will not change and we will not get data.theme. I need to define type with Theme type or what is the best way in this situation? |
@Elephmoon we already removed onMessage(event: MessageEvent<{ theme?: string }>) {
const isObject = typeof event.data === 'object' && event.data !== null && !Array.isArray(event.data)
if (!isObject) {
return
}
// work with data
} We set |
@Elephmoon we have the same data processing from post message in remark42/frontend/templates/iframe.ejs Line 141 in 345ee88
remark42/frontend/app/embed.ts Line 268 in 345ee88
|
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.
Sorry for the long response.
Thank you for your contribution!
1728b35
to
044294a
Compare
@Mavrin could you please review the PR? I've added some additional code, could be cool to have second opinion on 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.
lgtm
@Elephmoon can you rebase all of this into a single commit so I could merge it nicely? |
@Elephmoon hi, do you need help with it? |
Sorry. I’m moving to other city right now, I believe that I have time today evening and I will solve it |
33ddb9f
to
faaccba
Compare
Ugh. I made incorrect rebase and lost all changes (; |
@Elephmoon I'll try to revert it ;) |
044294a
to
0a98982
Compare
@Elephmoon I've fixed it, Is it okay for you to merge it with squash? |
0a98982
to
54679a2
Compare
Yep. I squashed it |
@umputun good to merge ;) |
Resolve #897
I searched through the files in the frontend, in all places where I found postMessage removed unnecessary serialization.
Also, I think if we haven't stringify, then we don't need to check for string type here.
remark42/frontend/app/components/root/root.tsx
Line 187 in 553bcf2