fix: quick add input got removed sometimes with syncing service

pull/6489/head
Peng Xiao 2022-08-23 11:26:41 +08:00
parent fb0ac634d2
commit ebfcba284e
2 changed files with 18 additions and 2 deletions

View File

@ -139,6 +139,19 @@ const searchHandler = q => {
export default function App() {
const [theme, setTheme] = React.useState('light')
const [model, setModel] = React.useState(documentModel)
// Mimic external reload event
React.useEffect(() => {
const interval = setInterval(() => {
setModel(onLoad())
}, 5000)
return () => {
clearInterval(interval)
}
}, [])
return (
<div className={`h-screen w-screen`}>
<ThemeSwitcher theme={theme} setTheme={setTheme} />
@ -157,7 +170,7 @@ export default function App() {
saveAsset: fileToBase64,
makeAssetUrl: a => a,
}}
model={documentModel}
model={model}
onPersist={onPersist}
/>
</div>

View File

@ -122,7 +122,10 @@ export class TLHistory<S extends TLShape = TLShape, K extends TLEventMap = TLEve
}
}
// Any shapes remaining in the shapes map need to be removed
if (shapesMap.size > 0) page.removeShapes(...shapesMap.values())
// Do not remove shapes when state is in the middle of a creation
if (shapesMap.size > 0 && !this.app.selectedTool.isIn('creating')) {
page.removeShapes(...shapesMap.values())
}
// Add any new shapes
if (shapesToAdd.length > 0) page.addShapes(...shapesToAdd)
// Remove the page from the map