Merge pull request #373 from w3irdrobot/disable-mark-all-read

Update mark all read dm button to be disabled when no unreads
This commit is contained in:
Kieran 2023-02-28 16:13:40 +00:00 committed by GitHub
commit 1ad0270819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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