file-association
Steve Ruiz 2021-11-05 07:03:44 +00:00
rodzic e3775c4c12
commit 39f56d564a
2 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -4,9 +4,11 @@ import { Decoration, TLDrawDocument, TLDrawShapeType } from '~types'
export function migrate(document: TLDrawDocument, newVersion: number): TLDrawDocument {
const { version = 0 } = document
console.log(`Migrating document from ${version} to ${newVersion}.`)
if (version === newVersion) return document
if (version <= 12) {
if (version <= 13) {
Object.values(document.pages).forEach((page) => {
Object.values(page.bindings).forEach((binding) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any

Wyświetl plik

@ -100,10 +100,13 @@ export class TLDrawState extends StateManager<Data> {
onChange?: (tlstate: TLDrawState, data: Data, reason: string) => void,
onUserChange?: (tlstate: TLDrawState, user: TLDrawUser) => void
) {
super(TLDrawState.defaultState, id, TLDrawState.version, (prev, next) => {
super(TLDrawState.defaultState, id, TLDrawState.version, (prev, next, prevVersion) => {
return {
...next,
document: migrate({ ...next.document, ...prev.document, version: 0 }, TLDrawState.version),
document: migrate(
{ ...next.document, ...prev.document, version: prevVersion },
TLDrawState.version
),
}
})
@ -2458,7 +2461,7 @@ export class TLDrawState extends StateManager<Data> {
}
}
static version = 12.6
static version = 13
static defaultDocument: TLDrawDocument = {
id: 'doc',