Skip to content

Commit

Permalink
chore(editor): remove unused awareness slot (#9640)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Jan 11, 2025
1 parent 446b31b commit 5b92567
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions blocksuite/framework/store/src/yjs/awareness.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Slot } from '@blocksuite/global/utils';
import type { Awareness } from 'y-protocols/awareness.js';

export interface UserInfo {
Expand All @@ -11,7 +10,6 @@ type UserSelection = Array<Record<string, unknown>>;
export type RawAwarenessState = {
user?: UserInfo;
color?: string;
// use v2 to avoid crush on old clients
selectionV2: Record<string, UserSelection>;
};

Expand All @@ -22,51 +20,14 @@ export interface AwarenessEvent {
}

export class AwarenessStore {
private readonly _onAwarenessChange = (diff: {
added: number[];
removed: number[];
updated: number[];
}) => {
const { added, removed, updated } = diff;

const states = this.getStates();
added.forEach(id => {
this.slots.update.emit({
id,
type: 'add',
state: states.get(id),
});
});
updated.forEach(id => {
this.slots.update.emit({
id,
type: 'update',
state: states.get(id),
});
});
removed.forEach(id => {
this.slots.update.emit({
id,
type: 'remove',
});
});
};

readonly awareness: Awareness;

readonly slots = {
update: new Slot<AwarenessEvent>(),
};

constructor(awareness: Awareness) {
this.awareness = awareness;
this.awareness.on('change', this._onAwarenessChange);
this.awareness.setLocalStateField('selectionV2', {});
}

destroy() {
this.awareness.off('change', this._onAwarenessChange);
this.slots.update.dispose();
this.awareness.destroy();
}

Expand Down

0 comments on commit 5b92567

Please sign in to comment.