Skip to content
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 certain iOS editors failing to load and save note content #42

Merged
merged 5 commits into from
Aug 9, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/componentRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,26 @@ export default class ComponentRelay {
}
}

// Mobile environment sends data as JSON string.
const { data } = event
const parsedData = isValidJsonString(data) ? JSON.parse(data) : data

if (!parsedData) {
Logger.error('Invalid data received. Skipping...')
return
}

/**
* The first message will be the most reliable one, so we won't change it after any subsequent events,
moughxyz marked this conversation as resolved.
Show resolved Hide resolved
* in case you receive an event from another window.
*/
if (!this.component.origin) {
if (parsedData.action === ComponentAction.ComponentRegistered) {
SebTota marked this conversation as resolved.
Show resolved Hide resolved
this.component.origin = event.origin
} else if (event.origin !== this.component.origin) {
// If event origin doesn't match first-run value, return.
return
}

// Mobile environment sends data as JSON string.
const { data } = event
const parsedData = isValidJsonString(data) ? JSON.parse(data) : data

if (!parsedData) {
Logger.error('Invalid data received. Skipping...')
return
}

this.handleMessage(parsedData)
}

Expand Down