From 8629bd5fc8738b0f9dd8f400893f833d4495916e Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Sun, 14 Jul 2024 20:08:01 +0200 Subject: [PATCH] fix bug where object list would not update --- dist/index.js | 10 ++++++---- src/Views/Objects/objectPane.tsx | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 2eeecaaa..2d0fbbad 100644 --- a/dist/index.js +++ b/dist/index.js @@ -608,7 +608,7 @@ showObjects: "mostrar objetos", createObject: "a\xF1adir nuevo objeto", untitledObject: "Sin T\xEDtulo", - filterObjects: "filtrar objetos", + filterObjects: "Filtrar objetos", searchByTitle: "Buscar por t\xEDtulo", searchByTitlePlaceholder: "Mi Objeto", searchTitleText: (term, resultCount) => term == "" ? `Objetos en total: ${resultCount}` : `Resultados por "${term}": ${resultCount}`, @@ -2093,15 +2093,17 @@ function applyFilter() { appliedFilter.value = filterInput.value; } - appliedFilter.subscribe((filterTerm) => { + function updateObjects() { const allObjects = [...chat.objects.value.entries()]; const matchingObjects = allObjects.filter( - (entry) => entry[1].title.indexOf(filterTerm) != -1 + (entry) => entry[1].title.indexOf(appliedFilter.value) != -1 ); resultCount.value = matchingObjects.length; messageObjects.clear(); matchingObjects.forEach((entry) => messageObjects.set(...entry)); - }); + } + bulkSubscribe([appliedFilter, chat.objects], updateObjects); + updateObjects(); const objectModal = createProxyState( [chat.objects, selectedObject], () => { diff --git a/src/Views/Objects/objectPane.tsx b/src/Views/Objects/objectPane.tsx index 4b8bb8c7..e1724ea9 100644 --- a/src/Views/Objects/objectPane.tsx +++ b/src/Views/Objects/objectPane.tsx @@ -61,15 +61,17 @@ export function ObjectPane(chat: Chat) { appliedFilter.value = filterInput.value; } - appliedFilter.subscribe((filterTerm) => { + function updateObjects() { const allObjects = [...chat.objects.value.entries()]; const matchingObjects = allObjects.filter( - (entry) => entry[1].title.indexOf(filterTerm) != -1 + (entry) => entry[1].title.indexOf(appliedFilter.value) != -1 ); resultCount.value = matchingObjects.length; messageObjects.clear(); matchingObjects.forEach((entry) => messageObjects.set(...entry)); - }); + } + React.bulkSubscribe([appliedFilter, chat.objects], updateObjects); + updateObjects(); // view const objectModal = React.createProxyState(