interface: surface and dismiss unread counts

This commit is contained in:
Liam Fitzgerald 2021-04-07 13:53:10 +10:00
parent 1c939b4861
commit 887a12ba0c
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 9 additions and 7 deletions

View File

@ -54,6 +54,7 @@ function GroupFeed(props) {
return;
}
api.graph.getNewest(graphResource.ship, graphResource.name, 100);
api.hark.markCountAsRead(association, '/', 'post');
}, [graphPath]);
if (!graphPath) {

View File

@ -24,6 +24,7 @@ import { Workspace } from '~/types/workspace';
import useGroupState from '~/logic/state/group';
import useMetadataState from '~/logic/state/metadata';
import {IS_SAFARI} from '~/logic/lib/platform';
import useHarkState from '~/logic/state/hark';
export function SidebarListHeader(props: {
api: GlobalApi;
@ -54,15 +55,15 @@ export function SidebarListHeader(props: {
const noun = (props.workspace?.type === 'messages') ? 'Messages' : 'Channels';
const isFeedEnabled =
metadata &&
metadata.config &&
metadata.config.group &&
'resource' in metadata.config.group;
const feedPath = metadata?.config?.group?.resource;
const unreadCount = useHarkState(
s => s.unreads?.graph?.[feedPath ?? ""]?.["/"]?.unreads as number ?? 0
);
return (
<Box>
{( isFeedEnabled ) ? (
{( !!feedPath) ? (
<Row
flexShrink="0"
alignItems="center"
@ -87,7 +88,7 @@ export function SidebarListHeader(props: {
props.history.push(`/~landscape${groupPath}/feed`);
}}
>
<Text>
<Text color={unreadCount > 0 ? 'blue' : 'black'}>
Group Feed
</Text>
</Row>