From a04ef2976089a9fe2e64b98ab2ae7a3cc9043118 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 14:25:23 -0500 Subject: [PATCH 01/11] add authored comments tag as a property of the document --- src/models/stores/create-exemplar-docs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/models/stores/create-exemplar-docs.ts b/src/models/stores/create-exemplar-docs.ts index c31815b1cf..0ffd91db12 100644 --- a/src/models/stores/create-exemplar-docs.ts +++ b/src/models/stores/create-exemplar-docs.ts @@ -80,7 +80,10 @@ function createExemplarDocs( type: ExemplarDocument, visibility: "public", content: exemplarData.content, - key: exemplarDocId + key: exemplarDocId, + properties: { + authoredCommentTag: exemplarData.tag + } }; makeDocFromData(newDocParams, documents, appConfig); }); From 7b0de59fb9b91fbc71304f6ca3bae3cceca7ed06 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 15:24:02 -0500 Subject: [PATCH 02/11] catalog documents that have authored tags --- src/models/stores/sorted-documents.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index 9bfb052ae0..fb0bb39657 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -137,6 +137,17 @@ export class SortedDocuments { //*************************************** Sort By Strategy ************************************** get sortByStrategy(): SortedDocument[]{ + const docKeysWithAuthoredTags: any = []; + this.documents.all.forEach(doc => { + if (doc.getProperty("authoredCommentTag")) { + docKeysWithAuthoredTags.push({ + tag: doc.getProperty("authoredCommentTag"), + keys: [doc.key] + }); + } + }); + console.log("| docKeysWithAuthoredTags: ", docKeysWithAuthoredTags); + const commentTags = this.commentTags; const tagsWithDocs: Record = {}; if (commentTags) { From 35adba6ad2c10bfb78083289ddd350eecb6969b8 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 22:16:40 -0500 Subject: [PATCH 03/11] wip, notes --- src/models/stores/sorted-documents.ts | 43 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index fb0bb39657..7c362f0ce5 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -137,16 +137,16 @@ export class SortedDocuments { //*************************************** Sort By Strategy ************************************** get sortByStrategy(): SortedDocument[]{ - const docKeysWithAuthoredTags: any = []; - this.documents.all.forEach(doc => { - if (doc.getProperty("authoredCommentTag")) { - docKeysWithAuthoredTags.push({ - tag: doc.getProperty("authoredCommentTag"), - keys: [doc.key] - }); - } - }); - console.log("| docKeysWithAuthoredTags: ", docKeysWithAuthoredTags); + // const docsWithAuthoredTags: any = []; + // this.documents.all.forEach(doc => { + // if (doc.getProperty("authoredCommentTag")) { + // // NOTE: we are assuming only one tag from CMS per document? + // docsWithAuthoredTags.push({ + // tag: doc.getProperty("authoredCommentTag"), + // doc + // }); + // } + // }); const commentTags = this.commentTags; const tagsWithDocs: Record = {}; @@ -186,6 +186,13 @@ export class SortedDocuments { if (tagsWithDocs[""]) { tagsWithDocs[""].docKeysFoundWithTag.push(doc.key); } + // HEY: I think you can do everything right here + if (doc.getProperty("authoredCommentTag")) { + const labelStr = doc.getProperty("authoredCommentTag"); + if (tagsWithDocs[labelStr]) { + tagsWithDocs[labelStr].docKeysFoundWithTag.push(doc.key); + } + } } }); @@ -200,6 +207,22 @@ export class SortedDocuments { documents }); }); + // console.log("\n\n| docsWithAuthoredTags: ", docsWithAuthoredTags); + // console.log("| tagsWithDocs: ", tagsWithDocs); + // console.log("| sortedDocsArr: ", sortedDocsArr); + + // this.documents.all.forEach(doc => { + // if (doc.getProperty("authoredCommentTag")) { + // const labelStr = doc.getProperty("authoredCommentTag"); + // sortedDocsArr.forEach((section: SortedDocument) => { + // console.log("section.sectionLabel: ", section.sectionLabel, "vs labelStr: ", labelStr); + // if (section.sectionLabel === labelStr) { + // section.documents.push(doc); + // } + // }); + // } + // }); + return sortedDocsArr; } From 8f8132df916acb6b4d2bd16c485e773407c94896 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 22:17:20 -0500 Subject: [PATCH 04/11] ok --- src/models/stores/sorted-documents.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index 7c362f0ce5..f6658b2a6b 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -188,10 +188,10 @@ export class SortedDocuments { } // HEY: I think you can do everything right here if (doc.getProperty("authoredCommentTag")) { - const labelStr = doc.getProperty("authoredCommentTag"); - if (tagsWithDocs[labelStr]) { - tagsWithDocs[labelStr].docKeysFoundWithTag.push(doc.key); - } + // const labelStr = doc.getProperty("authoredCommentTag"); + // if (tagsWithDocs[labelStr]) { + // tagsWithDocs[labelStr].docKeysFoundWithTag.push(doc.key); + // } } } }); From ae569e0c22b9c990b4893994b18190404c0c81c4 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 22:28:52 -0500 Subject: [PATCH 05/11] cleanup --- src/models/stores/sorted-documents.ts | 37 ++++----------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index f6658b2a6b..f008e5d548 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -137,17 +137,6 @@ export class SortedDocuments { //*************************************** Sort By Strategy ************************************** get sortByStrategy(): SortedDocument[]{ - // const docsWithAuthoredTags: any = []; - // this.documents.all.forEach(doc => { - // if (doc.getProperty("authoredCommentTag")) { - // // NOTE: we are assuming only one tag from CMS per document? - // docsWithAuthoredTags.push({ - // tag: doc.getProperty("authoredCommentTag"), - // doc - // }); - // } - // }); - const commentTags = this.commentTags; const tagsWithDocs: Record = {}; if (commentTags) { @@ -186,12 +175,11 @@ export class SortedDocuments { if (tagsWithDocs[""]) { tagsWithDocs[""].docKeysFoundWithTag.push(doc.key); } - // HEY: I think you can do everything right here - if (doc.getProperty("authoredCommentTag")) { - // const labelStr = doc.getProperty("authoredCommentTag"); - // if (tagsWithDocs[labelStr]) { - // tagsWithDocs[labelStr].docKeysFoundWithTag.push(doc.key); - // } + const foundTagKey = doc.getProperty("authoredCommentTag"); + if (foundTagKey !== undefined && foundTagKey !== "") { + if (tagsWithDocs[foundTagKey]) { + tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key); + } } } }); @@ -207,21 +195,6 @@ export class SortedDocuments { documents }); }); - // console.log("\n\n| docsWithAuthoredTags: ", docsWithAuthoredTags); - // console.log("| tagsWithDocs: ", tagsWithDocs); - // console.log("| sortedDocsArr: ", sortedDocsArr); - - // this.documents.all.forEach(doc => { - // if (doc.getProperty("authoredCommentTag")) { - // const labelStr = doc.getProperty("authoredCommentTag"); - // sortedDocsArr.forEach((section: SortedDocument) => { - // console.log("section.sectionLabel: ", section.sectionLabel, "vs labelStr: ", labelStr); - // if (section.sectionLabel === labelStr) { - // section.documents.push(doc); - // } - // }); - // } - // }); return sortedDocsArr; } From eed93dd8ebe6e714182c01514f072ec6ca550882 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 22:43:21 -0500 Subject: [PATCH 06/11] move out of test for empty tag --- src/models/stores/sorted-documents.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index f008e5d548..f3dfc676f6 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -175,11 +175,11 @@ export class SortedDocuments { if (tagsWithDocs[""]) { tagsWithDocs[""].docKeysFoundWithTag.push(doc.key); } - const foundTagKey = doc.getProperty("authoredCommentTag"); - if (foundTagKey !== undefined && foundTagKey !== "") { - if (tagsWithDocs[foundTagKey]) { - tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key); - } + } + const foundTagKey = doc.getProperty("authoredCommentTag"); + if (foundTagKey !== undefined && foundTagKey !== "") { + if (tagsWithDocs[foundTagKey]) { + tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key); } } }); From 9ff298ef6dbcc2af94185ee9148813d383542cd5 Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Wed, 6 Mar 2024 22:45:41 -0500 Subject: [PATCH 07/11] cleanup --- src/models/stores/sorted-documents.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index f3dfc676f6..c6b90d6bfb 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -195,7 +195,6 @@ export class SortedDocuments { documents }); }); - return sortedDocsArr; } From bf592ad5a031f885fd220927f949c87bccf8e3ab Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Thu, 7 Mar 2024 10:46:57 -0500 Subject: [PATCH 08/11] if doc has cms-sourced tag, remove it's key from list of docs with empty tag --- src/models/stores/sorted-documents.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index c6b90d6bfb..be8f435c31 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -180,6 +180,9 @@ export class SortedDocuments { if (foundTagKey !== undefined && foundTagKey !== "") { if (tagsWithDocs[foundTagKey]) { tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key); + // if tagsWithDocs[""] has this doc.key, remove it + const index = tagsWithDocs[""].docKeysFoundWithTag.indexOf(doc.key); + if (index > -1) tagsWithDocs[""].docKeysFoundWithTag.splice(index, 1); } } }); From 42b201002fdc6f9a77bdc42adc3576428f91a67e Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Thu, 7 Mar 2024 12:52:00 -0500 Subject: [PATCH 09/11] add exemplar tagging to cypress test - add tags in content.json - add comment/tag routines to test --- .../teacher_sort_work_view_spec.js | 44 +++++++++++++++++-- cypress/support/elements/common/ChatPanel.js | 10 ++--- cypress/support/elements/common/SortedWork.js | 7 ++- .../demo/units/qa-config-subtabs/content.json | 3 +- .../problem-1/exemplar-1/content.json | 2 +- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js index 4ea5450d02..70a2fbf771 100644 --- a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js +++ b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js @@ -3,11 +3,14 @@ import SortedWork from "../../../support/elements/common/SortedWork"; import ResourcesPanel from "../../../support/elements/common/ResourcesPanel"; import Canvas from '../../../support/elements/common/Canvas'; import ClueHeader from '../../../support/elements/common/cHeader'; +import ChatPanel from "../../../support/elements/common/ChatPanel"; let sortWork = new SortedWork; let resourcesPanel = new ResourcesPanel; let dashboard = new TeacherDashboard; let header = new ClueHeader; +let chatPanel = new ChatPanel; + const canvas = new Canvas; const title = "1.1 Unit Toolbar Configuration"; const copyTitle = "Personal Workspace"; @@ -45,13 +48,13 @@ describe('SortWorkView Tests', () => { sortWork.getSortByMenu().click(); // Open the sort menu cy.wait(1000); - sortWork.getListItemByName().click(); //Select 'Name' sort type + sortWork.getSortByNameOption().click(); //Select 'Name' sort type cy.wait(1000); sortWork.getSortByMenu().click(); // Open the sort menu again cy.wait(1000); - sortWork.getListItemByGroup().click(); // Select 'Group' sort type + sortWork.getSortByGroupOption().click(); // Select 'Group' sort type cy.wait(1000); cy.log('verify opening and closing a document from the sort work view'); @@ -147,13 +150,48 @@ describe('SortWorkView Tests', () => { cy.log("check that problem and exemplar documents can be sorted by name"); sortWork.getSortByMenu().click(); cy.wait(1000); - sortWork.getListItemByName().click(); + sortWork.getSortByNameOption().click(); sortWork.checkSectionHeaderLabelsExist([ "1, Student", "1, Teacher", "2, Student", "3, Student", "4, Student", "Idea, Ivan" ]); sortWork.checkDocumentInGroup("Idea, Ivan", exemplarDocs[0]); sortWork.checkDocumentInGroup("1, Student", studentProblemDocs[0]); + cy.log("check that exemplar document is displayed in strategy tag sourced from CMS"); + sortWork.getSortByMenu().click(); + cy.wait(1000); + sortWork.getSortByTagOption().click(); + sortWork.checkDocumentInGroup("Unit Rate", exemplarDocs[0]); + + cy.log("check that exemplar document can also be assigned tag by teacher"); + sortWork.getSortWorkItem().contains(exemplarDocs[0]).click(); + chatPanel.getChatPanelToggle().click(); + chatPanel.addCommentTagAndVerify("Diverging Designs"); + + cy.log("check that exemplar document is displayed in new tag"); + chatPanel.getChatCloseButton().click(); + cy.openTopTab('sort-work'); + // at the moment this is required to refresh the sort + sortWork.getSortByMenu().click(); + sortWork.getSortByNameOption().click(); + sortWork.getSortByMenu().click(); + sortWork.getSortByTagOption().click(); + sortWork.checkDocumentInGroup("Diverging Designs", exemplarDocs[0]); + + cy.log("remove the teacher added tag and reload"); + sortWork.getSortWorkItem().contains(exemplarDocs[0]).click(); + chatPanel.getChatPanelToggle().click(); + chatPanel.deleteTeacherComments(); + cy.wait(1000); + cy.visit(queryParams2); + cy.waitForLoad(); + cy.openTopTab('sort-work'); + + cy.log("check that exemplar document is still displayed in strategy tag sourced from CMS"); + sortWork.getSortByMenu().click(); + sortWork.getSortByTagOption().click(); + sortWork.checkDocumentInGroup("Unit Rate", exemplarDocs[0]); + cy.log("run CLUE as a student:1 and join group 6"); runClueAsStudent(students[0], 6); diff --git a/cypress/support/elements/common/ChatPanel.js b/cypress/support/elements/common/ChatPanel.js index 56d82ed426..cda61aff23 100644 --- a/cypress/support/elements/common/ChatPanel.js +++ b/cypress/support/elements/common/ChatPanel.js @@ -16,7 +16,7 @@ class ChatPanel{ this.getChatPanelToggle().click(); cy.wait(10000); } - }) + }); } getChatPanel() { return cy.get('.chat-panel'); @@ -202,9 +202,9 @@ class ChatPanel{ cy.wait(1000); } }) - ) + ); } else { - cy.log("No Comments to Delete"); + cy.log("No Comments to Delete"); } }); } @@ -219,7 +219,7 @@ class ChatPanel{ this.getCommentedDocumentList().find('.document-box').then(((value) => { totalCount = Cypress.$(value).length; expect(value).to.have.length(totalCount); - for(i=0; i < totalCount; i++) { + for(i=0; i < totalCount; i++) { this.getCommentedDocumentList().find('.document-box').eq(i).click({ force: true }); cy.wait(3000); this.addDocumentCommentAndVerify("This is " + (i+1) + " document list comment"); @@ -229,7 +229,7 @@ class ChatPanel{ cy.wait(3000); } }) - ) + ); } } export default ChatPanel; diff --git a/cypress/support/elements/common/SortedWork.js b/cypress/support/elements/common/SortedWork.js index 03089b63e3..c8ba071244 100644 --- a/cypress/support/elements/common/SortedWork.js +++ b/cypress/support/elements/common/SortedWork.js @@ -2,12 +2,15 @@ class SortedWork { getSortByMenu() { return cy.get('.custom-select.sort-work-sort-menu'); } - getListItemByName() { + getSortByNameOption() { return cy.get('[data-test="list-item-name"]'); } - getListItemByGroup() { + getSortByGroupOption() { return cy.get('[data-test="list-item-group"]'); } + getSortByTagOption(){ + return cy.get('[data-test="list-item-identify-design approach"]'); + } getSortWorkItem() { return cy.get(".sort-work-view .sorted-sections .list-item .footer .info"); } diff --git a/src/public/demo/units/qa-config-subtabs/content.json b/src/public/demo/units/qa-config-subtabs/content.json index c61d4c38f4..6a541f153b 100644 --- a/src/public/demo/units/qa-config-subtabs/content.json +++ b/src/public/demo/units/qa-config-subtabs/content.json @@ -57,7 +57,8 @@ "materials": "Varies Material/Surface", "physical": "Varies Physical Factors", "user": "Varies Human Factors", - "system": "Varies System Factors" + "system": "Varies System Factors", + "unit-rate": "Unit Rate" }, "tagPrompt": "Identify Design Approach", "tools": ["Simulator"], diff --git a/src/public/demo/units/qa-config-subtabs/exemplars/investigation-1/problem-1/exemplar-1/content.json b/src/public/demo/units/qa-config-subtabs/exemplars/investigation-1/problem-1/exemplar-1/content.json index b490a50de6..6678afc796 100644 --- a/src/public/demo/units/qa-config-subtabs/exemplars/investigation-1/problem-1/exemplar-1/content.json +++ b/src/public/demo/units/qa-config-subtabs/exemplars/investigation-1/problem-1/exemplar-1/content.json @@ -1,6 +1,6 @@ { "title": "First Exemplar", - "tag": "building-up", + "tag": "unit-rate", "content": { "tiles": [ { From 0b084e6651952dc9ffc808c9a7873019ce3bc23f Mon Sep 17 00:00:00 2001 From: Joseph Bacal Date: Thu, 7 Mar 2024 14:22:00 -0500 Subject: [PATCH 10/11] also assert that teacher created tag is removed from doc --- .../functional/teacher_tests/teacher_sort_work_view_spec.js | 3 ++- cypress/support/elements/common/SortedWork.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js index 70a2fbf771..eb28c8560f 100644 --- a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js +++ b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js @@ -187,10 +187,11 @@ describe('SortWorkView Tests', () => { cy.waitForLoad(); cy.openTopTab('sort-work'); - cy.log("check that exemplar document is still displayed in strategy tag sourced from CMS"); + cy.log("check that exemplar document is still displayed in strategy tag sourced from CMS but not in teacher added tag"); sortWork.getSortByMenu().click(); sortWork.getSortByTagOption().click(); sortWork.checkDocumentInGroup("Unit Rate", exemplarDocs[0]); + sortWork.checkGroupIsEmpty("Diverging Designs"); cy.log("run CLUE as a student:1 and join group 6"); runClueAsStudent(students[0], 6); diff --git a/cypress/support/elements/common/SortedWork.js b/cypress/support/elements/common/SortedWork.js index c8ba071244..6a6af6fcb0 100644 --- a/cypress/support/elements/common/SortedWork.js +++ b/cypress/support/elements/common/SortedWork.js @@ -20,6 +20,10 @@ class SortedWork { checkDocumentNotInGroup(groupName, doc) { cy.get(".sort-work-view .sorted-sections .section-header-label").contains(groupName).parent().parent().find(".list .list-item .footer .info").should("not.contain", doc); } + checkGroupIsEmpty(groupName){ + cy.get(".sort-work-view .sorted-sections .section-header-label") + .contains(groupName).parent().parent().find(".list").should('be.empty'); + } checkGroupDoesNotExist(group) { cy.get(".sort-work-view .sorted-sections .section-header-label").should("not.contain", group); } From 8d897e1e1f520a493adb0aab06b197e49464d2b5 Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Mon, 11 Mar 2024 13:53:31 -0400 Subject: [PATCH 11/11] refactor identifying document with and without tags for sort work --- src/models/stores/sorted-documents.ts | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index be8f435c31..f7536dc747 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -41,7 +41,7 @@ interface IMatchPropertiesOptions { } export class SortedDocuments { stores: ISortedDocumentsStores; - tempTagDocumentMap = new Map>(); + firestoreTagDocumentMap = new Map>(); constructor(stores: ISortedDocumentsStores) { makeAutoObservable(this); @@ -156,33 +156,36 @@ export class SortedDocuments { // Find all unique document keys in tagsWithDocs. Compare this with all sortable documents // in store to find "Documents with no comments" then place those doc keys to "Not Tagged" - const uniqueDocKeysWithComments = new Set(); + const uniqueDocKeysWithTags = new Set(); - this.tempTagDocumentMap.forEach((docKeysSet, tag) => { - docKeysSet.forEach((docKey: string) =>{ - uniqueDocKeysWithComments.add(docKey); - }); + // grouping documents based on firestore comment tags + this.firestoreTagDocumentMap.forEach((docKeysSet, tag) => { const docKeysArray = Array.from(docKeysSet); // Convert the Set to an array if (tagsWithDocs[tag]) { + docKeysSet.forEach((docKey: string) =>{ + uniqueDocKeysWithTags.add(docKey); + }); tagsWithDocs[tag].docKeysFoundWithTag = docKeysArray; } }); + // adding in (exemplar) documents with authored tags const allSortableDocKeys = this.filteredDocsByType; allSortableDocKeys.forEach(doc => { - if (!uniqueDocKeysWithComments.has(doc.key)) { - // This document has no comments - if (tagsWithDocs[""]) { - tagsWithDocs[""].docKeysFoundWithTag.push(doc.key); - } - } const foundTagKey = doc.getProperty("authoredCommentTag"); if (foundTagKey !== undefined && foundTagKey !== "") { if (tagsWithDocs[foundTagKey]) { tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key); - // if tagsWithDocs[""] has this doc.key, remove it - const index = tagsWithDocs[""].docKeysFoundWithTag.indexOf(doc.key); - if (index > -1) tagsWithDocs[""].docKeysFoundWithTag.splice(index, 1); + uniqueDocKeysWithTags.add(doc.key); + } + } + }); + + allSortableDocKeys.forEach(doc => { + if (!uniqueDocKeysWithTags.has(doc.key)) { + // This document has no comments + if (tagsWithDocs[""]) { + tagsWithDocs[""].docKeysFoundWithTag.push(doc.key); } } }); @@ -214,10 +217,10 @@ export class SortedDocuments { const commentData = commentDoc.data(); if (commentData?.tags) { commentData.tags.forEach((tag: string) => { - let docKeysSet = this.tempTagDocumentMap.get(tag); + let docKeysSet = this.firestoreTagDocumentMap.get(tag); if (!docKeysSet) { docKeysSet = new ObservableSet(); - this.tempTagDocumentMap.set(tag, docKeysSet); + this.firestoreTagDocumentMap.set(tag, docKeysSet); } docKeysSet.add(doc.key); });