From 176fdb5425fae7ab130026b6126b47ff5ecac904 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Mon, 18 Mar 2024 07:56:53 +0000 Subject: [PATCH] Skip the random ID for regular history entries (#3183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 - [ ] `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 --- packages/editor/api-report.md | 1 - packages/editor/api/api.json | 2 +- packages/editor/src/lib/editor/managers/HistoryManager.ts | 6 ++---- packages/editor/src/lib/editor/types/history-types.ts | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/editor/api-report.md b/packages/editor/api-report.md index 95c359eba..e3a6d8906 100644 --- a/packages/editor/api-report.md +++ b/packages/editor/api-report.md @@ -1964,7 +1964,6 @@ export type TLCollaboratorHintProps = { // @public (undocumented) export type TLCommand = { type: 'command'; - id: string; data: Data; name: Name; preservesRedoStack?: boolean; diff --git a/packages/editor/api/api.json b/packages/editor/api/api.json index 990b2e8f7..0b38a1d21 100644 --- a/packages/editor/api/api.json +++ b/packages/editor/api/api.json @@ -35941,7 +35941,7 @@ }, { "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", diff --git a/packages/editor/src/lib/editor/managers/HistoryManager.ts b/packages/editor/src/lib/editor/managers/HistoryManager.ts index a223df9a3..2b0511598 100644 --- a/packages/editor/src/lib/editor/managers/HistoryManager.ts +++ b/packages/editor/src/lib/editor/managers/HistoryManager.ts @@ -82,7 +82,6 @@ export class HistoryManager< this._undos.update((undos) => undos.tail.push({ ...prev, - id: uniqueId(), data: devFreeze(handle.squash!(prev.data, data)), }) ) @@ -93,7 +92,6 @@ export class HistoryManager< type: 'command', name, data: devFreeze(data), - id: uniqueId(), preservesRedoStack: preservesRedoStack, }) ) @@ -117,9 +115,9 @@ export class HistoryManager< this._batchDepth++ if (this._batchDepth === 1) { transact(() => { - const mostRecentActionId = this._undos.get().head?.id + const mostRecentAction = this._undos.get().head fn() - if (mostRecentActionId !== this._undos.get().head?.id) { + if (mostRecentAction !== this._undos.get().head) { this.onBatchComplete() } }) diff --git a/packages/editor/src/lib/editor/types/history-types.ts b/packages/editor/src/lib/editor/types/history-types.ts index 0ab03b479..6adfa2de7 100644 --- a/packages/editor/src/lib/editor/types/history-types.ts +++ b/packages/editor/src/lib/editor/types/history-types.ts @@ -25,7 +25,6 @@ export type TLHistoryMark = { /** @public */ export type TLCommand = { type: 'command' - id: string data: Data name: Name /**