Skip the random ID for regular history entries (#3183)
Non-mark history entries don't need a random id. 🤷♂️ ### Change Type - [x] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [ ] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [ ] `internal` — Does not affect user-facing stuff <!-- ❗ Please select a 'Type' label ❗️ --> - [ ] `bugfix` — Bug fix - [ ] `feature` — New feature - [x] `improvement` — Improving existing features - [ ] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know
This commit is contained in:
parent
4801b35768
commit
176fdb5425
4 changed files with 3 additions and 7 deletions
|
@ -1964,7 +1964,6 @@ export type TLCollaboratorHintProps = {
|
||||||
// @public (undocumented)
|
// @public (undocumented)
|
||||||
export type TLCommand<Name extends string = any, Data = any> = {
|
export type TLCommand<Name extends string = any, Data = any> = {
|
||||||
type: 'command';
|
type: 'command';
|
||||||
id: string;
|
|
||||||
data: Data;
|
data: Data;
|
||||||
name: Name;
|
name: Name;
|
||||||
preservesRedoStack?: boolean;
|
preservesRedoStack?: boolean;
|
||||||
|
|
|
@ -35941,7 +35941,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
"text": "{\n type: 'command';\n id: string;\n data: Data;\n name: Name;\n preservesRedoStack?: boolean;\n}"
|
"text": "{\n type: 'command';\n data: Data;\n name: Name;\n preservesRedoStack?: boolean;\n}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
|
|
@ -82,7 +82,6 @@ export class HistoryManager<
|
||||||
this._undos.update((undos) =>
|
this._undos.update((undos) =>
|
||||||
undos.tail.push({
|
undos.tail.push({
|
||||||
...prev,
|
...prev,
|
||||||
id: uniqueId(),
|
|
||||||
data: devFreeze(handle.squash!(prev.data, data)),
|
data: devFreeze(handle.squash!(prev.data, data)),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -93,7 +92,6 @@ export class HistoryManager<
|
||||||
type: 'command',
|
type: 'command',
|
||||||
name,
|
name,
|
||||||
data: devFreeze(data),
|
data: devFreeze(data),
|
||||||
id: uniqueId(),
|
|
||||||
preservesRedoStack: preservesRedoStack,
|
preservesRedoStack: preservesRedoStack,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -117,9 +115,9 @@ export class HistoryManager<
|
||||||
this._batchDepth++
|
this._batchDepth++
|
||||||
if (this._batchDepth === 1) {
|
if (this._batchDepth === 1) {
|
||||||
transact(() => {
|
transact(() => {
|
||||||
const mostRecentActionId = this._undos.get().head?.id
|
const mostRecentAction = this._undos.get().head
|
||||||
fn()
|
fn()
|
||||||
if (mostRecentActionId !== this._undos.get().head?.id) {
|
if (mostRecentAction !== this._undos.get().head) {
|
||||||
this.onBatchComplete()
|
this.onBatchComplete()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,7 +25,6 @@ export type TLHistoryMark = {
|
||||||
/** @public */
|
/** @public */
|
||||||
export type TLCommand<Name extends string = any, Data = any> = {
|
export type TLCommand<Name extends string = any, Data = any> = {
|
||||||
type: 'command'
|
type: 'command'
|
||||||
id: string
|
|
||||||
data: Data
|
data: Data
|
||||||
name: Name
|
name: Name
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue