Removed app publish state tracking
This commit is contained in:
parent
998f1806aa
commit
2bdf855217
|
@ -22,15 +22,10 @@
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { apps } from "stores/portal"
|
import { apps } from "stores/portal"
|
||||||
import {
|
import { store } from "builderStore"
|
||||||
store,
|
|
||||||
screenHistoryStore,
|
|
||||||
automationHistoryStore,
|
|
||||||
} from "builderStore"
|
|
||||||
import TourWrap from "components/portal/onboarding/TourWrap.svelte"
|
import TourWrap from "components/portal/onboarding/TourWrap.svelte"
|
||||||
import { TOUR_STEP_KEYS } from "components/portal/onboarding/tours.js"
|
import { TOUR_STEP_KEYS } from "components/portal/onboarding/tours.js"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import { isEqual, cloneDeep } from "lodash"
|
|
||||||
|
|
||||||
export let application
|
export let application
|
||||||
export let loaded
|
export let loaded
|
||||||
|
@ -62,80 +57,7 @@
|
||||||
$store.version &&
|
$store.version &&
|
||||||
$store.upgradableVersion !== $store.version
|
$store.upgradableVersion !== $store.version
|
||||||
|
|
||||||
let cachedVersion = $store.version + ""
|
$: canPublish = !publishing && loaded
|
||||||
let versionAltered = false
|
|
||||||
let screensAltered = false
|
|
||||||
let automationsAltered = false
|
|
||||||
|
|
||||||
let publishRecord = {
|
|
||||||
screenHistory: null,
|
|
||||||
automationHistory: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
//Meta Changes
|
|
||||||
let appMeta = {}
|
|
||||||
let appMetaUpdated = false
|
|
||||||
let appMetaInitialised = false
|
|
||||||
|
|
||||||
store.subscribe(state => {
|
|
||||||
let { name, url: appUrl, navigation, theme, customTheme, icon } = state
|
|
||||||
const update = {
|
|
||||||
name,
|
|
||||||
url: appUrl,
|
|
||||||
navigation: { ...cloneDeep(navigation) },
|
|
||||||
theme,
|
|
||||||
customTheme,
|
|
||||||
icon,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isEqual(update, appMeta)) {
|
|
||||||
if (!appMetaInitialised) {
|
|
||||||
appMetaInitialised = true
|
|
||||||
} else {
|
|
||||||
appMetaUpdated = true
|
|
||||||
}
|
|
||||||
appMeta = {
|
|
||||||
...(appMeta || {}),
|
|
||||||
...update,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const monitorHistoryStore = (historyStore, publishedHistoryId, cb) => {
|
|
||||||
if (!historyStore.history.length || historyStore.loading) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!historyStore.canUndo) {
|
|
||||||
cb(publishedHistoryId != -1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const historyEntry = historyStore.history[historyStore.position - 1]
|
|
||||||
|
|
||||||
if (historyEntry) {
|
|
||||||
cb(publishedHistoryId != historyEntry.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$: monitorHistoryStore(
|
|
||||||
$screenHistoryStore,
|
|
||||||
publishRecord.screenHistory,
|
|
||||||
updated => {
|
|
||||||
screensAltered = updated
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
$: monitorHistoryStore(
|
|
||||||
$automationHistoryStore,
|
|
||||||
publishRecord.automationHistory,
|
|
||||||
updated => {
|
|
||||||
automationsAltered = updated
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
$: versionAltered = cachedVersion != $store.version
|
|
||||||
$: altered =
|
|
||||||
screensAltered || appMetaUpdated || automationsAltered || versionAltered
|
|
||||||
$: canPublish = (!isPublished || altered) && !publishing && loaded
|
|
||||||
|
|
||||||
const initialiseApp = async () => {
|
const initialiseApp = async () => {
|
||||||
const applicationPkg = await API.fetchAppPackage($store.devId)
|
const applicationPkg = await API.fetchAppPackage($store.devId)
|
||||||
|
@ -191,27 +113,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetAppHistory = (historyStore, historyKey) => {
|
|
||||||
if (historyStore.history.length) {
|
|
||||||
const historyEntryPos = historyStore.position
|
|
||||||
const historyEntry = historyStore.history[historyEntryPos - 1]
|
|
||||||
|
|
||||||
publishRecord = {
|
|
||||||
...publishRecord,
|
|
||||||
[historyKey]: historyEntry?.id || -1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const resetStateTracking = () => {
|
|
||||||
resetAppHistory($automationHistoryStore, "automationHistory")
|
|
||||||
resetAppHistory($screenHistoryStore, "screenHistory")
|
|
||||||
automationsAltered = false
|
|
||||||
screensAltered = false
|
|
||||||
appMetaUpdated = false
|
|
||||||
cachedVersion = $store.version + ""
|
|
||||||
}
|
|
||||||
|
|
||||||
async function publishApp() {
|
async function publishApp() {
|
||||||
try {
|
try {
|
||||||
publishing = true
|
publishing = true
|
||||||
|
@ -224,7 +125,6 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
await completePublish()
|
await completePublish()
|
||||||
resetStateTracking()
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
analytics.captureException(error)
|
analytics.captureException(error)
|
||||||
|
@ -255,7 +155,6 @@
|
||||||
type: "success",
|
type: "success",
|
||||||
icon: "GlobeStrike",
|
icon: "GlobeStrike",
|
||||||
})
|
})
|
||||||
publishRecord = {}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error("Error unpublishing app")
|
notifications.error("Error unpublishing app")
|
||||||
}
|
}
|
||||||
|
@ -452,12 +351,8 @@
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<RevertModal bind:this={revertModal} onComplete={resetStateTracking} />
|
<RevertModal bind:this={revertModal} />
|
||||||
<VersionModal
|
<VersionModal hideIcon bind:this={versionModal} />
|
||||||
hideIcon
|
|
||||||
bind:this={versionModal}
|
|
||||||
onComplete={resetStateTracking}
|
|
||||||
/>
|
|
||||||
{:else}
|
{:else}
|
||||||
<div class="app-action-button preview-locked">
|
<div class="app-action-button preview-locked">
|
||||||
<div class="app-action">
|
<div class="app-action">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
$: appUrl = `${window.origin}/embed${app?.url}`
|
$: appUrl = `${window.origin}/embed${app?.url}`
|
||||||
$: appDeployed = app?.status === AppStatus.DEPLOYED
|
$: appDeployed = app?.status === AppStatus.DEPLOYED
|
||||||
|
|
||||||
$: embed = `<iframe width="800" height="600" frameborder="0" allow="clipboard-write;camera" src="${appUrl}" ></iframe>`
|
$: embed = `<iframe width="800" height="600" frameborder="0" allow="clipboard-write;camera" src="${appUrl}"></iframe>`
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Layout noPadding>
|
<Layout noPadding>
|
||||||
|
|
Loading…
Reference in New Issue