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) {
|
if (!this.block) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { service } = this.block;
|
const surfaceRefs = this.block.std.store
|
||||||
const surfaceRefs = service.doc
|
|
||||||
.getBlocksByFlavour('affine:surface-ref')
|
.getBlocksByFlavour('affine:surface-ref')
|
||||||
.map(block => block.model) as SurfaceRefBlockModel[];
|
.map(block => block.model) as SurfaceRefBlockModel[];
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
||||||
import type { BaseSelection, UserInfo } from '@blocksuite/store';
|
import type { BaseSelection, UserInfo } from '@blocksuite/store';
|
||||||
import { computed, effect } from '@preact/signals-core';
|
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 { state } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
import throttle from 'lodash-es/throttle';
|
import throttle from 'lodash-es/throttle';
|
||||||
@@ -269,6 +269,32 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._remoteColorManager = new RemoteColorManager(this.std);
|
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() {
|
override disconnectedCallback() {
|
||||||
@@ -302,37 +328,6 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
|
|||||||
60
|
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() {
|
override render() {
|
||||||
if (this._selections.length === 0) {
|
if (this._selections.length === 0) {
|
||||||
return nothing;
|
return nothing;
|
||||||
|
|||||||
@@ -259,14 +259,16 @@ export class ChatPanel extends SignalWatcher(
|
|||||||
this.embeddingProgress = [0, 0];
|
this.embeddingProgress = [0, 0];
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override updated(_changedProperties: PropertyValues) {
|
protected override willUpdate(_changedProperties: PropertyValues) {
|
||||||
if (_changedProperties.has('doc')) {
|
if (_changedProperties.has('doc')) {
|
||||||
this._resetPanel();
|
this._resetPanel();
|
||||||
requestAnimationFrame(async () => {
|
requestAnimationFrame(async () => {
|
||||||
await this._initPanel();
|
await this._initPanel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override updated(_changedProperties: PropertyValues) {
|
||||||
if (this.chatContextValue.status === 'loading') {
|
if (this.chatContextValue.status === 'loading') {
|
||||||
// reset the wheel triggered flag when the status is loading
|
// reset the wheel triggered flag when the status is loading
|
||||||
this._wheelTriggered = false;
|
this._wheelTriggered = false;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export class AIChatComposer extends SignalWatcher(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override updated(_changedProperties: PropertyValues) {
|
protected override willUpdate(_changedProperties: PropertyValues) {
|
||||||
if (_changedProperties.has('doc')) {
|
if (_changedProperties.has('doc')) {
|
||||||
this._resetComposer();
|
this._resetComposer();
|
||||||
requestAnimationFrame(async () => {
|
requestAnimationFrame(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user