fix(editor): lit change-in-update warning (#11904)

This PR fixed that lit change-in-update warning. Related #9446

### Before

![CleanShot 2025-04-23 at 02.18.16@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/e1205c41-7890-4de8-ba14-99a88f66a9ac.png)

### After
![CleanShot 2025-04-23 at 02.18.42@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/45bff6e5-a56f-43ac-abe9-6da9b75baca5.png)
This commit is contained in:
L-Sun
2025-04-22 20:25:54 +00:00
parent 45b6cbe8d7
commit 020c1a7598
4 changed files with 32 additions and 36 deletions

View File

@@ -288,8 +288,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {
if (!this.block) {
return;
}
const { service } = this.block;
const surfaceRefs = service.doc
const surfaceRefs = this.block.std.store
.getBlocksByFlavour('affine:surface-ref')
.map(block => block.model) as SurfaceRefBlockModel[];

View File

@@ -17,7 +17,7 @@ import {
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
import type { BaseSelection, UserInfo } from '@blocksuite/store';
import { computed, effect } from '@preact/signals-core';
import { css, html, nothing, type PropertyValues } from 'lit';
import { css, html, nothing } from 'lit';
import { state } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import throttle from 'lodash-es/throttle';
@@ -269,6 +269,32 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
});
this._remoteColorManager = new RemoteColorManager(this.std);
this.disposables.add(
effect(() => {
const selections = this._remoteSelections.value;
this._updateSelectionsThrottled(selections);
})
);
this.disposables.add(
this.std.store.slots.blockUpdated.subscribe(() => {
this._updateSelectionsThrottled(this._remoteSelections.peek());
})
);
const gfx = this.std.get(GfxControllerIdentifier);
this.disposables.add(
gfx.viewport.viewportUpdated.subscribe(() => {
const selections = this._remoteSelections.peek();
this._updateSelections(selections);
})
);
this.disposables.add(
this.std.event.active$.subscribe(value => {
if (!value) {
this.std.selection.clearRemote();
}
})
);
}
override disconnectedCallback() {
@@ -302,37 +328,6 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
60
);
protected override firstUpdated(_changedProperties: PropertyValues): void {
this.disposables.add(
effect(() => {
const selections = this._remoteSelections.value;
this._updateSelectionsThrottled(selections);
})
);
this.disposables.add(
this.std.store.slots.blockUpdated.subscribe(() => {
this._updateSelectionsThrottled(this._remoteSelections.peek());
})
);
const gfx = this.std.get(GfxControllerIdentifier);
this.disposables.add(
gfx.viewport.viewportUpdated.subscribe(() => {
const selections = this._remoteSelections.peek();
this._updateSelections(selections);
})
);
this.disposables.add(
this.std.event.active$.subscribe(value => {
if (!value) {
this.std.selection.clearRemote();
}
})
);
}
override render() {
if (this._selections.length === 0) {
return nothing;