diff --git a/commafeed-client/src/app/slices/user.ts b/commafeed-client/src/app/slices/user.ts index d8b04ee7..e8dabb38 100644 --- a/commafeed-client/src/app/slices/user.ts +++ b/commafeed-client/src/app/slices/user.ts @@ -43,6 +43,11 @@ export const changeScrollSpeed = createAsyncThunk("settings/showRead", (showRead, thunkApi) => { + const { settings } = thunkApi.getState().user + if (!settings) return + client.user.saveSettings({ ...settings, showRead }) +}) export const changeSharingSetting = createAsyncThunk( "settings/sharingSetting", (sharingSetting, thunkApi) => { @@ -85,16 +90,23 @@ export const userSlice = createSlice({ if (!state.settings) return state.settings.scrollSpeed = action.meta.arg ? 400 : 0 }) + builder.addCase(changeShowRead.pending, (state, action) => { + if (!state.settings) return + state.settings.showRead = action.meta.arg + }) builder.addCase(changeSharingSetting.pending, (state, action) => { if (!state.settings) return state.settings.sharingSettings[action.meta.arg.site] = action.meta.arg.value }) - builder.addMatcher(isAnyOf(changeLanguage.fulfilled, changeScrollSpeed.fulfilled, changeSharingSetting.fulfilled), () => { - showNotification({ - message: t`Settings saved.`, - color: "green", - }) - }) + builder.addMatcher( + isAnyOf(changeLanguage.fulfilled, changeScrollSpeed.fulfilled, changeShowRead.fulfilled, changeSharingSetting.fulfilled), + () => { + showNotification({ + message: t`Settings saved.`, + color: "green", + }) + } + ) }, }) diff --git a/commafeed-client/src/components/settings/DisplaySettings.tsx b/commafeed-client/src/components/settings/DisplaySettings.tsx index 37cb7c56..b745c35a 100644 --- a/commafeed-client/src/components/settings/DisplaySettings.tsx +++ b/commafeed-client/src/components/settings/DisplaySettings.tsx @@ -1,7 +1,7 @@ import { t } from "@lingui/macro" import { Divider, Select, SimpleGrid, Stack, Switch } from "@mantine/core" import { Constants } from "app/constants" -import { changeLanguage, changeScrollSpeed, changeSharingSetting } from "app/slices/user" +import { changeLanguage, changeScrollSpeed, changeSharingSetting, changeShowRead } from "app/slices/user" import { useAppDispatch, useAppSelector } from "app/store" import { SharingSettings } from "app/types" import { locales } from "i18n" @@ -9,6 +9,7 @@ import { locales } from "i18n" export function DisplaySettings() { const language = useAppSelector(state => state.user.settings?.language) const scrollSpeed = useAppSelector(state => state.user.settings?.scrollSpeed) + const showRead = useAppSelector(state => state.user.settings?.showRead) const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings) const dispatch = useAppDispatch() @@ -30,6 +31,12 @@ export function DisplaySettings() { onChange={e => dispatch(changeScrollSpeed(e.currentTarget.checked))} /> + dispatch(changeShowRead(e.currentTarget.checked))} + /> + diff --git a/commafeed-client/src/components/sidebar/Tree.tsx b/commafeed-client/src/components/sidebar/Tree.tsx index 926d80c6..411437a8 100644 --- a/commafeed-client/src/components/sidebar/Tree.tsx +++ b/commafeed-client/src/components/sidebar/Tree.tsx @@ -22,6 +22,7 @@ const errorThreshold = 9 export function Tree() { const root = useAppSelector(state => state.tree.rootCategory) const source = useAppSelector(state => state.entries.source) + const showRead = useAppSelector(state => state.user.settings?.showRead) const dispatch = useAppDispatch() const feedClicked = (e: React.MouseEvent, id: string) => { @@ -74,13 +75,16 @@ export function Tree() { ) const categoryNode = (category: Category, level: number = 0) => { + const unreadCount = categoryUnreadCount(category) + if (unreadCount === 0 && !showRead) return null + const hasError = !category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => f.errorCount > errorThreshold)) return ( ( - errorThreshold} - onClick={feedClicked} - key={feed.id} - /> - ) + const feedNode = (feed: Subscription, level: number = 0) => { + if (feed.unread === 0 && !showRead) return null + + return ( + errorThreshold} + onClick={feedClicked} + key={feed.id} + /> + ) + } const recursiveCategoryNode = (category: Category, level: number = 0) => ( diff --git a/commafeed-client/src/locales/en/messages.po b/commafeed-client/src/locales/en/messages.po index efd6c1bf..8cea0ddf 100644 --- a/commafeed-client/src/locales/en/messages.po +++ b/commafeed-client/src/locales/en/messages.po @@ -577,6 +577,10 @@ msgstr "Sharing sites" msgid "Shift" msgstr "Shift" +#: src/components/settings/DisplaySettings.tsx +msgid "Show feeds and categories with no unread entries" +msgstr "Show feeds and categories with no unread entries" + #: src/components/KeyboardShortcutsHelp.tsx msgid "Show keyboard shortcut help" msgstr "Show keyboard shortcut help" diff --git a/commafeed-client/src/locales/fr/messages.po b/commafeed-client/src/locales/fr/messages.po index 70003f80..819956ce 100644 --- a/commafeed-client/src/locales/fr/messages.po +++ b/commafeed-client/src/locales/fr/messages.po @@ -577,6 +577,10 @@ msgstr "Sites de partage" msgid "Shift" msgstr "Maj" +#: src/components/settings/DisplaySettings.tsx +msgid "Show feeds and categories with no unread entries" +msgstr "Afficher les flux et les catégories pour lesquels tout est déjà lu" + #: src/components/KeyboardShortcutsHelp.tsx msgid "Show keyboard shortcut help" msgstr "Montrer les raccourcis clavier"