Fix bug with db

This commit is contained in:
Steve Ruiz 2021-08-18 07:04:01 +01:00
parent aa20ed8d63
commit 74f600aac2
3 changed files with 6 additions and 4 deletions

View file

@ -60,7 +60,9 @@ export function usePersistence(id: string, doc: TLDrawDocument) {
const db = await openDB<TLDatabase>('db', VERSION, {
upgrade(db, oldVersion, newVersion) {
if (newVersion) {
if (newVersion > oldVersion) {
db.deleteObjectStore('documents')
}
db.createObjectStore('documents')
}
},

View file

@ -5,8 +5,6 @@ export function duplicatePage(data: Data, pageId: string): Command {
const newId = Utils.uniqueId()
const { currentPageId } = data.appState
console.log('duplicating')
const page = data.document.pages[pageId]
const nextPage = {

View file

@ -60,7 +60,9 @@ export function usePersistence(id: string, doc: TLDrawDocument) {
const db1 = await openDB<TLDatabase>('db1', VERSION, {
upgrade(db, oldVersion, newVersion) {
if (newVersion) {
if (newVersion > oldVersion) {
db.deleteObjectStore('documents')
}
db.createObjectStore('documents')
}
},