Skip to content

Commit

Permalink
Add a condition to filter events for use in devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 committed Apr 25, 2024
1 parent 15a22cf commit 33d5fb7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/devtools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {
DocEventType,
Document,
Indexable,
TransactionEvent,
Expand Down Expand Up @@ -72,6 +73,22 @@ export function setupDevtools<T, P extends Indexable>(

transactionEventsByDocKey.set(doc.getKey(), []);
const unsub = doc.subscribe('all', (event) => {
if (
event.some(
(docEvent) =>
docEvent.type !== DocEventType.StatusChanged &&
docEvent.type !== DocEventType.Snapshot &&
docEvent.type !== DocEventType.LocalChange &&
docEvent.type !== DocEventType.RemoteChange &&
docEvent.type !== DocEventType.Initialized &&
docEvent.type !== DocEventType.Watched &&
docEvent.type !== DocEventType.Unwatched &&
docEvent.type !== DocEventType.PresenceChanged,
)
) {
return;
}

transactionEventsByDocKey.get(doc.getKey())!.push(event);
if (devtoolsStatus === 'synced') {
sendToPanel({
Expand Down

0 comments on commit 33d5fb7

Please sign in to comment.