Update mark all read dm button to be disabled when no unreads

This commit is contained in:
w3irdrobot 2023-02-27 23:37:30 -05:00
parent 5f6f8f5c44
commit 564701c8b8
Signed by: w3irdrobot
GPG Key ID: 3E6DBBB622F3155C

View File

@ -33,6 +33,8 @@ export default function MessagesPage() {
); );
}, [dms, myPubKey, dmInteraction]); }, [dms, myPubKey, dmInteraction]);
const unreadCount = useMemo(() => chats.reduce((p, c) => p + c.unreadMessages, 0), [chats]);
function noteToSelf(chat: DmChat) { function noteToSelf(chat: DmChat) {
return ( return (
<div className="flex mb10" key={chat.pubkey}> <div className="flex mb10" key={chat.pubkey}>
@ -69,7 +71,7 @@ export default function MessagesPage() {
<h3 className="f-grow"> <h3 className="f-grow">
<FormattedMessage {...messages.Messages} /> <FormattedMessage {...messages.Messages} />
</h3> </h3>
<button type="button" onClick={() => markAllRead()}> <button disabled={unreadCount <= 0} type="button" onClick={() => markAllRead()}>
<FormattedMessage {...messages.MarkAllRead} /> <FormattedMessage {...messages.MarkAllRead} />
</button> </button>
</div> </div>