mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 02:35:58 +08:00
fix(editor): lit change-in-update warning (#11904)
This PR fixed that lit change-in-update warning. Related #9446 ### Before  ### After 
This commit is contained in:
@@ -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[];
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user