Browse Source
Merge pull request #2205 from Budibase/fix/preview-garbage-handling
Allow app preview to handle garbage iframe messages
pull/2232/head
Andrew Kingston
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
13 additions and
1 deletions
-
packages/builder/src/components/design/AppPreview/iframeTemplate.js
|
|
|
@ -47,6 +47,18 @@ export default ` |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// Parse received message
|
|
|
|
// If parsing fails, just ignore and wait for the next message
|
|
|
|
let parsed |
|
|
|
try { |
|
|
|
parsed = JSON.parse(event.data) |
|
|
|
} catch (error) { |
|
|
|
// Ignore
|
|
|
|
} |
|
|
|
if (!parsed) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// Extract data from message
|
|
|
|
const { |
|
|
|
selectedComponentId, |
|
|
|
@ -55,7 +67,7 @@ export default ` |
|
|
|
previewType, |
|
|
|
appId, |
|
|
|
theme |
|
|
|
} = JSON.parse(event.data) |
|
|
|
} = parsed |
|
|
|
|
|
|
|
// Set some flags so the app knows we're in the builder
|
|
|
|
window["##BUDIBASE_IN_BUILDER##"] = true |
|
|
|
|