Skip to content

Commit

Permalink
remove unnecessary debounce which caused missed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed May 30, 2024
1 parent a64a0e5 commit 82a437f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions src/public/app/widgets/type_widgets/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import libraryLoader from '../../services/library_loader.js';
import TypeWidget from './type_widget.js';
import utils from '../../services/utils.js';
import linkService from '../../services/link.js';
import debounce from '../../services/debounce.js';

const TPL = `
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
Expand Down Expand Up @@ -103,8 +102,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.SCENE_VERSION_INITIAL = -1; // -1 indicates that it is fresh. excalidraw scene version is always >0
this.SCENE_VERSION_ERROR = -2; // -2 indicates error

// config
this.DEBOUNCE_TIME_ONCHANGEHANDLER = 750; // ms
// ensure that assets are loaded from trilium
window.EXCALIDRAW_ASSET_PATH = `${window.location.origin}/node_modules/@excalidraw/excalidraw/dist/`;

Expand All @@ -117,11 +114,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.$widget;
this.reactHandlers; // used to control react state

// binds
this.createExcalidrawReactApp = this.createExcalidrawReactApp.bind(this);
this.onChangeHandler = this.onChangeHandler.bind(this);
this.isNewSceneVersion = this.isNewSceneVersion.bind(this);

this.libraryChanged = false;
}

Expand Down Expand Up @@ -153,7 +145,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {

ReactDOM.unmountComponentAtNode(renderElement);
const root = ReactDOM.createRoot(renderElement);
root.render(React.createElement(this.createExcalidrawReactApp));
root.render(React.createElement(() => this.createExcalidrawReactApp()));
});

return this.$widget;
Expand Down Expand Up @@ -445,7 +437,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {

this.saveData();
},
onChange: debounce(this.onChangeHandler, this.DEBOUNCE_TIME_ONCHANGEHANDLER),
onChange: () => this.onChangeHandler(),
viewModeEnabled: false,
zenModeEnabled: false,
gridModeEnabled: false,
Expand Down

0 comments on commit 82a437f

Please sign in to comment.