From f82fe21c6ba8dfad116c3d18c2dd81cfe562b682 Mon Sep 17 00:00:00 2001 From: Bernt Popp Date: Fri, 12 Apr 2024 00:08:38 +0200 Subject: [PATCH] fix(genes-table): Enhance reactivity in table updates post-curation Resolved an issue in the Genes Table where individual entries were not being updated in real-time after curation or precuration. The solution involved improving the reactivity of the component by ensuring the `rawItems` state is correctly updated and reflects the latest gene data. This fix enhances user experience by displaying up-to-date curation statuses without needing to reload the entire table. Further testing has confirmed the effective real-time update of individual entries post-curation or precuration actions. Closes #112 --- src/stores/geneStore.js | 26 ++++++++++++++++++++++++++ src/views/GenesTable.vue | 24 +++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/stores/geneStore.js b/src/stores/geneStore.js index 1f389b1..376f9fb 100644 --- a/src/stores/geneStore.js +++ b/src/stores/geneStore.js @@ -154,6 +154,32 @@ export const getGeneByHGNCIdOrSymbol = async (identifier) => { }; +/** + * Retrieves a specific gene document from the Firestore 'genes' collection by document ID. + * + * @async + * @function getGeneByDocId + * @param {string} docId - The document ID of the gene to retrieve. + * @returns {Promise} - A promise that resolves to an object containing the gene data. + * @throws {Error} - Throws an error if the document doesn't exist or the retrieval fails. + * @description This function retrieves a specific gene document from the Firestore 'genes' collection using the provided document ID. + */ +export const getGeneByDocId = async (docId) => { + try { + const geneRef = doc(db, 'genes', docId); + const docSnap = await getDoc(geneRef); + + if (docSnap.exists()) { + return { docId: docSnap.id, ...docSnap.data() }; + } else { + throw new Error("Gene document not found"); + } + } catch (error) { + throw new Error(`Error retrieving gene by document ID: ${error.message}`); + } +}; + + /** * Parses a CSV string, checks against existing entries based on unique columns, * and writes or updates each row as a document in the 'genes' collection with timestamps. diff --git a/src/views/GenesTable.vue b/src/views/GenesTable.vue index 7bee38a..e691a14 100644 --- a/src/views/GenesTable.vue +++ b/src/views/GenesTable.vue @@ -39,7 +39,7 @@