Skip to content

Commit 736e639

Browse files
🩹 fix(BookCard): Do not erroneously display DELETED.
1 parent 686d117 commit 736e639

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

imports/ui/books/BookCard.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export default function BookCard({item}) {
3535

3636
const [year, book] = books.split(item.name);
3737

38-
const {result} = useBookStats(item.name);
38+
const {loading, found, result} = useBookStats(item.name);
3939
const {count, total, first, last} = result ?? {};
4040

41-
const subheader = count === undefined ? '...' : `${count} consultations`;
41+
const subheader = found ? `${count} consultations` : '...';
4242

4343
const content =
4444
count === undefined ? (
@@ -55,6 +55,8 @@ export default function BookCard({item}) {
5555

5656
return (
5757
<StaticTagCard
58+
loading={loading}
59+
found={found}
5860
tag={item}
5961
url={(_name) => `/book/${year}/${myEncodeURIComponent(book)}`}
6062
subheader={subheader}

imports/ui/books/useBookStats.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import subscribe from '../../api/publication/subscribe';
55
import publication from '../../api/publication/books/consultations/stats';
66
import {Stats as Collection} from '../../api/collection/books/stats';
77

8-
/**
9-
* useBookStats.
10-
*
11-
* @param {string} name
12-
*/
138
const useBookStats = (name: string) =>
149
useTracker(() => {
1510
const handle = subscribe(publication, name);
11+
const loading = !handle.ready();
12+
const result = Collection.findOne({name});
13+
const found = result !== undefined;
1614
return {
17-
loading: !handle.ready(),
18-
result: Collection.findOne({name}),
15+
loading,
16+
found,
17+
result,
1918
};
2019
}, [name]);
2120

0 commit comments

Comments
 (0)