1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Remove legacy performance hack of remove _revs from component definitions as this was sometimes leading to invalid JSON, preventing the app from loading

This commit is contained in:
Andrew Kingston 2021-12-06 17:59:23 +00:00
parent a0d8bffbc6
commit 0a3dede736

View file

@ -69,15 +69,7 @@
previewDevice: $store.previewDevice, previewDevice: $store.previewDevice,
messagePassing: $store.clientFeatures.messagePassing, messagePassing: $store.clientFeatures.messagePassing,
} }
// Saving pages and screens to the DB causes them to have _revs.
// These revisions change every time a save happens and causes
// these reactive statements to fire, even though the actual
// definition hasn't changed.
// By deleting all _rev properties we can avoid this and increase
// performance.
$: json = JSON.stringify(previewData) $: json = JSON.stringify(previewData)
$: strippedJson = json.replace(/"_rev":\s*"[^"]+"/g, `"_rev":""`)
// Update the iframe with the builder info to render the correct preview // Update the iframe with the builder info to render the correct preview
const refreshContent = message => { const refreshContent = message => {
@ -87,7 +79,7 @@
} }
// Refresh the preview when required // Refresh the preview when required
$: refreshContent(strippedJson) $: refreshContent(json)
function receiveMessage(message) { function receiveMessage(message) {
const handlers = { const handlers = {
@ -102,7 +94,7 @@
if (!$store.clientFeatures.intelligentLoading) { if (!$store.clientFeatures.intelligentLoading) {
loading = false loading = false
} }
refreshContent(strippedJson) refreshContent(json)
}, },
[MessageTypes.ERROR]: event => { [MessageTypes.ERROR]: event => {
// Catch any app errors // Catch any app errors