From aa340b21584e1e93114d1bc6e60733c05d9534dc Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Wed, 17 Jul 2019 10:04:20 +0200 Subject: [PATCH] Fix topic deletion child topic count --- app/src/actions/clearTopic.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/actions/clearTopic.ts b/app/src/actions/clearTopic.ts index 5bc4233..71874f3 100644 --- a/app/src/actions/clearTopic.ts +++ b/app/src/actions/clearTopic.ts @@ -13,7 +13,13 @@ export const clearTopic = (topic: q.TreeNode, recursive: boolean, subtopicC const topicCount = topic.childTopicCount() const deleteLimitMessage = topicCount > subtopicClearLimit ? ` You can only delete ${subtopicClearLimit} child topics at once.` : '' - const childTopicsMessage = topicCount > 0 ? ` and ${topicCount} child ${topicCount === 1 ? 'topic' : 'topics'}` : '' + + const topicDelta = topic.hasMessage() ? -1 : 0 + const childTopicsMessage = + topicCount + topicDelta > 0 + ? ` and ${topicCount + topicDelta} child ${topicCount + topicDelta === 1 ? 'topic' : 'topics'}` + : '' + const confirmed = await dispatch( globalActions.requestConfirmation( 'Confirm delete',