mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
always show current feed/category (#1543)
This commit is contained in:
@@ -35,6 +35,21 @@ export function Tree() {
|
|||||||
const showRead = useAppSelector(state => state.user.settings?.showRead)
|
const showRead = useAppSelector(state => state.user.settings?.showRead)
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
|
const isFeedDisplayed = (feed: Subscription) => {
|
||||||
|
const isCurrentFeed = source.type === "feed" && source.id === String(feed.id)
|
||||||
|
return isCurrentFeed || feed.unread > 0 || showRead
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCategoryDisplayed = (category: Category): boolean => {
|
||||||
|
const isCurrentCategory = source.type === "category" && source.id === category.id
|
||||||
|
return (
|
||||||
|
isCurrentCategory ||
|
||||||
|
showRead ||
|
||||||
|
category.children.some(c => isCategoryDisplayed(c)) ||
|
||||||
|
category.feeds.some(f => isFeedDisplayed(f))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const feedClicked = (e: React.MouseEvent, id: string) => {
|
const feedClicked = (e: React.MouseEvent, id: string) => {
|
||||||
if (e.detail === 2) {
|
if (e.detail === 2) {
|
||||||
dispatch(redirectToFeedDetails(id))
|
dispatch(redirectToFeedDetails(id))
|
||||||
@@ -97,8 +112,7 @@ export function Tree() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const categoryNode = (category: Category, level = 0) => {
|
const categoryNode = (category: Category, level = 0) => {
|
||||||
const unreadCount = categoryUnreadCount(category)
|
if (!isCategoryDisplayed(category)) return null
|
||||||
if (unreadCount === 0 && !showRead) return null
|
|
||||||
|
|
||||||
const hasError = !category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => f.errorCount > errorThreshold))
|
const hasError = !category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => f.errorCount > errorThreshold))
|
||||||
return (
|
return (
|
||||||
@@ -107,7 +121,7 @@ export function Tree() {
|
|||||||
type="category"
|
type="category"
|
||||||
name={category.name}
|
name={category.name}
|
||||||
icon={category.expanded ? expandedIcon : collapsedIcon}
|
icon={category.expanded ? expandedIcon : collapsedIcon}
|
||||||
unread={unreadCount}
|
unread={categoryUnreadCount(category)}
|
||||||
selected={source.type === "category" && source.id === category.id}
|
selected={source.type === "category" && source.id === category.id}
|
||||||
expanded={category.expanded}
|
expanded={category.expanded}
|
||||||
level={level}
|
level={level}
|
||||||
@@ -120,7 +134,7 @@ export function Tree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const feedNode = (feed: Subscription, level = 0) => {
|
const feedNode = (feed: Subscription, level = 0) => {
|
||||||
if (feed.unread === 0 && !showRead) return null
|
if (!isFeedDisplayed(feed)) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
|
|||||||
Reference in New Issue
Block a user