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(core): should be bound to the correct object (#8121)

fundon017e89f4589d
diff --git a/packages/frontend/core/src/modules/editor/entities/editor.ts b/packages/frontend/core/src/modules/editor/entities/editor.ts
index 1d55c0f3b0..466c5191ed 100644
--- a/packages/frontend/core/src/modules/editor/entities/editor.ts
+++ b/packages/frontend/core/src/modules/editor/entities/editor.ts
@@ -181,20 +181,20 @@ export class Editor extends Entity {
>('rich-text');
title?.inlineEditor.focusEnd();
}
- unsubs.push(
- focusAt$
- .distinctUntilChanged(
- (a, b) => a?.id === b?.id && a?.refreshKey === b?.refreshKey
- )
- .subscribe(params => {
- if (params?.id) {
- const std = editorContainer.host?.std;
- if (std) {
- scrollAnchoring(std, this.mode$.value, params.id);
- }
+
+ const subscription = focusAt$
+ .distinctUntilChanged(
+ (a, b) => a?.id === b?.id && a?.refreshKey === b?.refreshKey
+ )
+ .subscribe(params => {
+ if (params?.id) {
+ const std = editorContainer.host?.std;
+ if (std) {
+ scrollAnchoring(std, this.mode$.value, params.id);
}
- }).unsubscribe
- );
+ }
+ });
+ unsubs.push(subscription.unsubscribe.bind(subscription));
const edgelessPage = editorContainer.host?.querySelector(
'affine-edgeless-root'
@@ -205,13 +205,13 @@ export class Editor extends Entity {
this.isPresenting$.next(
edgelessPage.edgelessTool.type === 'frameNavigator'
);
- unsubs.push(
- edgelessPage.slots.edgelessToolUpdated.on(() => {
- this.isPresenting$.next(
- edgelessPage.edgelessTool.type === 'frameNavigator'
- );
- }).dispose
- );
+
+ const disposable = edgelessPage.slots.edgelessToolUpdated.on(() => {
+ this.isPresenting$.next(
+ edgelessPage.edgelessTool.type === 'frameNavigator'
+ );
+ });
+ unsubs.push(disposable.dispose.bind(disposable));
}
return () => {