Merge pull request #4739 from urbit/lf/post-hark

Group Feed: unread counts
This commit is contained in:
matildepark 2021-04-12 11:09:38 -04:00 committed by GitHub
commit 0d8b1862cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View File

@ -22,8 +22,9 @@
++ notification-kind
^- (unit notif-kind:hark)
=/ len (lent index.p.i)
?: =(1 len) ~
`[%post [(dec len) len] %none %children]
=/ =mode:hark
?:(=(1 len) %count %none)
`[%post [(dec len) len] mode %children]
::
++ transform-add-nodes
|= [=index =post =atom was-parent-modified=?]

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"
@ -90,6 +91,9 @@ export function SidebarListHeader(props: {
<Text>
Group Feed
</Text>
<Text mr="1" color="blue">
{ unreadCount > 0 && unreadCount}
</Text>
</Row>
) : null
}