replace old client with new client from commafeed-ui repository

This commit is contained in:
Athou
2022-08-13 10:56:07 +02:00
parent ac7b6eeb21
commit 04894f118b
183 changed files with 20326 additions and 12678 deletions

View File

@@ -0,0 +1,21 @@
import { Category } from "./types"
export function visitCategoryTree(category: Category, visitor: (category: Category) => void): void {
visitor(category)
category.children.forEach(child => visitCategoryTree(child, visitor))
}
export function flattenCategoryTree(category: Category): Category[] {
const categories: Category[] = []
visitCategoryTree(category, c => categories.push(c))
return categories
}
export function categoryUnreadCount(category?: Category): number {
if (!category) return 0
return flattenCategoryTree(category)
.flatMap(c => c.feeds)
.map(f => f.unread)
.reduce((total, current) => total + current, 0)
}