From 066389f6f359034e0ecba3e9982ca1e16e68520e Mon Sep 17 00:00:00 2001 From: Johan Bell Date: Tue, 10 Mar 2026 10:22:51 +0100 Subject: [PATCH 1/3] feat: Exclude Tag and Post documents from live results when contentOnly is true --- .../src/util/ApiLiveQuery/applySocketData.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shared/src/util/ApiLiveQuery/applySocketData.ts b/shared/src/util/ApiLiveQuery/applySocketData.ts index 7148434a50..a4295c7ef1 100644 --- a/shared/src/util/ApiLiveQuery/applySocketData.ts +++ b/shared/src/util/ApiLiveQuery/applySocketData.ts @@ -41,8 +41,24 @@ export function applySocketData( }) .map((doc) => doc.docId); + // When contentOnly is set for Tag/Post, exclude Tag and Post docs from the live result (only Content is wanted) + const excludeTagPostIds = + query.contentOnly && + query.types?.length && + (query.types.includes(DocType.Post) || query.types.includes(DocType.Tag)) + ? (data.docs as Array) + .filter( + (doc) => + doc.type === DocType.Post || + doc.type === DocType.Tag, + ) + .map((doc) => doc._id) + : []; + + const idsToRemove = Array.from(new Set([...toDeleteIds, ...excludeTagPostIds])); + destination.value = destination.value?.filter( - (doc) => !toDeleteIds.includes(doc._id), + (doc) => !idsToRemove.includes(doc._id), ) as Array; // Filter out delete commands from the result From d808b07f8eb94799351f3cf9047f834048352520 Mon Sep 17 00:00:00 2001 From: Johan Bell Date: Wed, 11 Mar 2026 19:56:19 +0100 Subject: [PATCH 2/3] refactor: Simplify filtering logic for live results by directly excluding Tag and Post documents when contentOnly is true --- .../src/util/ApiLiveQuery/applySocketData.ts | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/shared/src/util/ApiLiveQuery/applySocketData.ts b/shared/src/util/ApiLiveQuery/applySocketData.ts index a4295c7ef1..98459a4cb5 100644 --- a/shared/src/util/ApiLiveQuery/applySocketData.ts +++ b/shared/src/util/ApiLiveQuery/applySocketData.ts @@ -41,25 +41,20 @@ export function applySocketData( }) .map((doc) => doc.docId); + destination.value = destination.value?.filter( + (doc) => !toDeleteIds.includes(doc._id), + ) as Array; + // When contentOnly is set for Tag/Post, exclude Tag and Post docs from the live result (only Content is wanted) - const excludeTagPostIds = + if ( query.contentOnly && query.types?.length && (query.types.includes(DocType.Post) || query.types.includes(DocType.Tag)) - ? (data.docs as Array) - .filter( - (doc) => - doc.type === DocType.Post || - doc.type === DocType.Tag, - ) - .map((doc) => doc._id) - : []; - - const idsToRemove = Array.from(new Set([...toDeleteIds, ...excludeTagPostIds])); - - destination.value = destination.value?.filter( - (doc) => !idsToRemove.includes(doc._id), - ) as Array; + ) { + destination.value = destination.value?.filter( + (doc) => doc.type !== DocType.Post && doc.type !== DocType.Tag, + ); + } // Filter out delete commands from the result let docs = data.docs.filter((doc) => doc.type !== DocType.DeleteCmd); From 365ad9746961edcb4e96eaa300ca754264b30857 Mon Sep 17 00:00:00 2001 From: Johan Bell Date: Thu, 12 Mar 2026 15:12:09 +0100 Subject: [PATCH 3/3] refactor: Remove redundant filtering for Tag and Post documents in applySocketData function --- shared/src/util/ApiLiveQuery/applySocketData.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/shared/src/util/ApiLiveQuery/applySocketData.ts b/shared/src/util/ApiLiveQuery/applySocketData.ts index 98459a4cb5..7148434a50 100644 --- a/shared/src/util/ApiLiveQuery/applySocketData.ts +++ b/shared/src/util/ApiLiveQuery/applySocketData.ts @@ -45,17 +45,6 @@ export function applySocketData( (doc) => !toDeleteIds.includes(doc._id), ) as Array; - // When contentOnly is set for Tag/Post, exclude Tag and Post docs from the live result (only Content is wanted) - if ( - query.contentOnly && - query.types?.length && - (query.types.includes(DocType.Post) || query.types.includes(DocType.Tag)) - ) { - destination.value = destination.value?.filter( - (doc) => doc.type !== DocType.Post && doc.type !== DocType.Tag, - ); - } - // Filter out delete commands from the result let docs = data.docs.filter((doc) => doc.type !== DocType.DeleteCmd);