From c69c4cf3ddf611f9133c43ab07d43949cce592ae Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Wed, 19 Aug 2026 18:58:20 +0100 Subject: [PATCH] Refactor ApiServerContext to streamline data fetching and improve query structure - Simplified fetchTemplatePDF function by consolidating parameters into a single line for better readability. - Updated userNotifier fetch queries to use nested object syntax for improved clarity and consistency in data retrieval. - Enhanced overall code maintainability by reducing unnecessary line breaks and optimizing filter structures. --- .../Dashboard/context/ApiServerContext.jsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/Dashboard/context/ApiServerContext.jsx b/src/components/Dashboard/context/ApiServerContext.jsx index 8ddb068d..a457e8a5 100644 --- a/src/components/Dashboard/context/ApiServerContext.jsx +++ b/src/components/Dashboard/context/ApiServerContext.jsx @@ -1841,15 +1841,8 @@ const ApiServerProvider = ({ children }) => { const fetchTemplatePDF = async (id, content, testObject, callback) => { logger.debug('Fetching pdf template...') try { - const result = await fetchTemplateDownload( - id, - content, - testObject, - 'pdf' - ) - const payload = result.error - ? result - : { pdf: result.buffer || result } + const result = await fetchTemplateDownload(id, content, testObject, 'pdf') + const payload = result.error ? result : { pdf: result.buffer || result } if (typeof callback === 'function') { callback(payload) } @@ -2017,8 +2010,8 @@ const ApiServerProvider = ({ children }) => { if (!userProfile?._id) return { data: [] } const result = await fetchObjects('userNotifier', { filter: { - user: userProfile._id, - object: objectId, + 'user._id': userProfile._id, + 'object._id': objectId, objectType }, limit: 1 @@ -2029,7 +2022,7 @@ const ApiServerProvider = ({ children }) => { const fetchAllUserNotifiersForObject = async (objectId, objectType) => { const result = await fetchObjects('userNotifier', { filter: { - object: objectId, + 'object._id': objectId, objectType }, limit: 100