Fix the false-positive error in studio.extend
This removes the `Extension id "${extension.id}" is already defined` error when `studio.extend()` is in a hot-reloaded file but the extension hasn't actually changed.
This commit is contained in:
parent
1280de02d0
commit
5192c42548
1 changed files with 16 additions and 13 deletions
|
@ -275,9 +275,11 @@ export class Studio {
|
||||||
throw new Error(`extension.id must be a string`)
|
throw new Error(`extension.id must be a string`)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transaction(({drafts}) => {
|
const extensionId = extension.id
|
||||||
if (drafts.ephemeral.extensions.byId[extension.id]) {
|
|
||||||
const prevExtension = drafts.ephemeral.extensions.byId[extension.id]
|
const prevExtension =
|
||||||
|
this._store.getState().ephemeral.extensions.byId[extensionId]
|
||||||
|
if (prevExtension) {
|
||||||
if (
|
if (
|
||||||
extension === prevExtension ||
|
extension === prevExtension ||
|
||||||
shallowEqual(extension, prevExtension)
|
shallowEqual(extension, prevExtension)
|
||||||
|
@ -289,6 +291,7 @@ export class Studio {
|
||||||
throw new Error(`Extension id "${extension.id}" is already defined`)
|
throw new Error(`Extension id "${extension.id}" is already defined`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.transaction(({drafts}) => {
|
||||||
drafts.ephemeral.extensions.byId[extension.id] = extension
|
drafts.ephemeral.extensions.byId[extension.id] = extension
|
||||||
|
|
||||||
const allPaneClasses = drafts.ephemeral.extensions.paneClasses
|
const allPaneClasses = drafts.ephemeral.extensions.paneClasses
|
||||||
|
|
Loading…
Reference in a new issue