mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(editor): remove redundant getOptional for gfx (#10142)
This commit is contained in:
@@ -7,7 +7,7 @@ import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
||||
import { getViewportElement } from '@blocksuite/affine-shared/utils';
|
||||
import type { BlockComponent } from '@blocksuite/block-std';
|
||||
import { BLOCK_ID_ATTR, WidgetComponent } from '@blocksuite/block-std';
|
||||
import { GfxController } from '@blocksuite/block-std/gfx';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||
import { IS_MOBILE } from '@blocksuite/global/env';
|
||||
import {
|
||||
INLINE_ROOT_ATTR,
|
||||
@@ -197,8 +197,7 @@ export class AffineLinkedDocWidget extends WidgetComponent<
|
||||
}
|
||||
|
||||
private _watchViewportChange() {
|
||||
const gfx = this.std.getOptional(GfxController);
|
||||
if (!gfx) return;
|
||||
const gfx = this.std.get(GfxControllerIdentifier);
|
||||
this.disposables.add(
|
||||
gfx.viewport.viewportUpdated.on(() => {
|
||||
this._updateInputRects();
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
getViewportElement,
|
||||
} from '@blocksuite/affine-shared/utils';
|
||||
import { PropTypes, requiredProperties } from '@blocksuite/block-std';
|
||||
import { GfxController } from '@blocksuite/block-std/gfx';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||
import {
|
||||
SignalWatcher,
|
||||
throttle,
|
||||
@@ -341,10 +341,8 @@ export class LinkedDocPopover extends SignalWatcher(
|
||||
);
|
||||
}
|
||||
|
||||
const gfx = this.context.std.getOptional(GfxController);
|
||||
if (gfx) {
|
||||
this.disposables.add(gfx.viewport.viewportUpdated.on(updatePosition));
|
||||
}
|
||||
const gfx = this.context.std.get(GfxControllerIdentifier);
|
||||
this.disposables.add(gfx.viewport.viewportUpdated.on(updatePosition));
|
||||
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user