Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(plugin): use rxjs throttle

austarasfdeae3d43293
diff --git a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx
index 113dec843d..4155307f74 100644
--- a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx
+++ b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx
@@ -1,12 +1,15 @@
-import { BlockDomInfo, HookType } from '@toeverything/framework/virgo';
+import {
+ BlockDomInfo,
+ HookType,
+ BlockDropPlacement,
+} from '@toeverything/framework/virgo';
import { StrictMode } from 'react';
import { BasePlugin } from '../../base-plugin';
import { ignoreBlockTypes } from './menu-config';
import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable';
import { PluginRenderRoot } from '../../utils';
-import { Subject } from 'rxjs';
-import { domToRect, last, Point, throttle } from '@toeverything/utils';
-import { BlockDropPlacement } from '@toeverything/framework/virgo';
+import { Subject, throttleTime } from 'rxjs';
+import { domToRect, last, Point } from '@toeverything/utils';
const DRAG_THROTTLE_DELAY = 150;
export class LeftMenuPlugin extends BasePlugin {
private _mousedown?: boolean;
@@ -58,15 +61,10 @@ export class LeftMenuPlugin extends BasePlugin {
this.hooks.get(HookType.ON_ROOTNODE_DROP).subscribe(this._onDrop)
);
this.sub.add(
- this.hooks.get(HookType.ON_ROOTNODE_DRAG_OVER).subscribe(
- throttle(
- this._handleRootNodeDragover.bind(this),
- DRAG_THROTTLE_DELAY,
- {
- leading: true,
- }
- )
- )
+ this.hooks
+ .get(HookType.ON_ROOTNODE_DRAG_OVER)
+ .pipe(throttleTime(DRAG_THROTTLE_DELAY))
+ .subscribe(this._handleRootNodeDragover)
);
}