added private and public video counts

This commit is contained in:
MaximilianKos 2024-05-18 23:09:49 +02:00
parent f57368519f
commit 667a0a8719
3 changed files with 10 additions and 2 deletions

View File

@ -5,7 +5,7 @@ description: Fireshare Widget Configuration
Learn more about [Fireshare](https://github.com/ShaneIsrael/fireshare). Learn more about [Fireshare](https://github.com/ShaneIsrael/fireshare).
Allowed fields: `["total", "categories", "views"]`. Allowed fields: `["total", "categories", "views", "private", "public"]`.
```yaml ```yaml
widget: widget:

View File

@ -886,6 +886,8 @@
"fireshare": { "fireshare": {
"total": "Total", "total": "Total",
"categories": "Categories", "categories": "Categories",
"views": "Views" "views": "Views",
"private": "Private",
"public": "Public"
} }
} }

View File

@ -21,6 +21,8 @@ export default function Component({ service }) {
<Block label="fireshare.total" /> <Block label="fireshare.total" />
<Block label="fireshare.categories" /> <Block label="fireshare.categories" />
<Block label="fireshare.views" /> <Block label="fireshare.views" />
<Block label="fireshare.private" />
<Block label="fireshare.public" />
</Container> </Container>
); );
} }
@ -33,12 +35,16 @@ export default function Component({ service }) {
}); });
const categoriesCount = categoriesSet.size; const categoriesCount = categoriesSet.size;
const totalViews = infoData.videos.reduce((acc, video) => acc + video.view_count, 0); const totalViews = infoData.videos.reduce((acc, video) => acc + video.view_count, 0);
const privateCount = infoData.videos.filter(video => video.info.private).length;
const publicCount = total - privateCount;
return ( return (
<Container service={service}> <Container service={service}>
<Block label="fireshare.total" value={total} /> <Block label="fireshare.total" value={total} />
<Block label="fireshare.categories" value={categoriesCount} /> <Block label="fireshare.categories" value={categoriesCount} />
<Block label="fireshare.views" value={totalViews} /> <Block label="fireshare.views" value={totalViews} />
<Block label="fireshare.private" value={privateCount} />
<Block label="fireshare.public" value={publicCount} />
</Container> </Container>
); );
} }