add a markAllAsRead option on menus

This commit is contained in:
Audric Ackermann 2021-03-19 15:50:46 +11:00
parent 02fe7ad753
commit 1f509e003d
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4
10 changed files with 44 additions and 11 deletions

View File

@ -453,6 +453,10 @@
"unverify": {
"message": "Mark As Not Verified"
},
"markAllAsRead": {
"message": "Mark All as Read",
"description": "Shown on a menu to mark the whole convo as read."
},
"isNotVerified": {
"message": "You have not verified your safety number with $name$.",
"description": "Summary state shown at top of the safety number screen if user has not verified contact.",

View File

@ -363,6 +363,10 @@
}
}
},
"markAllAsRead": {
"message": "Tout Marquer Comme Lu",
"description": "Shown on a menu to mark the whole convo as read."
},
"isNotVerified": {
"message": "Vous navez pas vérifié votre numéro de sécurité avec $name$",
"description": "Summary state shown at top of the safety number screen if user has not verified contact.",

View File

@ -42,6 +42,7 @@ type PropsHousekeeping = {
onUnblockContact?: () => void;
onInviteContacts?: () => void;
onClearNickname?: () => void;
onMarkAllRead: () => void;
theme: DefaultTheme;
};
@ -62,7 +63,6 @@ class ConversationListItem extends React.PureComponent<Props> {
public renderAvatar() {
const {
avatarPath,
i18n,
name,
phoneNumber,
profileName,

View File

@ -83,6 +83,8 @@ interface Props {
onAvatarClick?: (userPubKey: string) => void;
onUpdateGroupName: () => void;
onMarkAllRead: () => void;
memberAvatars?: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails
theme: DefaultTheme;
}

View File

@ -434,6 +434,10 @@ export class SessionConversation extends React.Component<Props, State> {
window.Whisper.events.trigger('inviteContacts', conversation);
},
onMarkAllRead: () => {
void conversation.markReadBouncy(Date.now());
},
onAddModerators: () => {
window.Whisper.events.trigger('addModerators', conversation);
},

View File

@ -4,6 +4,7 @@ import {
getAddModeratorsMenuItem,
getBlockMenuItem,
getCopyMenuItem,
getMarkAllReadMenuItem,
getDeleteContactMenuItem,
getDeleteMessagesMenuItem,
getDisappearingMenuItem,
@ -31,6 +32,7 @@ export type PropsConversationHeaderMenu = {
onInviteContacts?: () => void;
onLeaveGroup: () => void;
onMarkAllRead: () => void;
onAddModerators: () => void;
onRemoveModerators: () => void;
onUpdateGroupName: () => void;
@ -55,6 +57,7 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
onDeleteMessages,
onDeleteContact,
onCopyPublicKey,
onMarkAllRead,
onLeaveGroup,
onAddModerators,
onRemoveModerators,
@ -86,6 +89,7 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
)}
{getCopyMenuItem(isPublic, isGroup, onCopyPublicKey, window.i18n)}
{getMarkAllReadMenuItem(onMarkAllRead, window.i18n)}
{getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)}
{getAddModeratorsMenuItem(
isAdmin,

View File

@ -5,6 +5,7 @@ import {
getBlockMenuItem,
getClearNicknameMenuItem,
getCopyMenuItem,
getMarkAllReadMenuItem,
getDeleteContactMenuItem,
getDeleteMessagesMenuItem,
getInviteContactMenuItem,
@ -25,6 +26,7 @@ export type PropsContextConversationItem = {
onDeleteContact?: () => void;
onLeaveGroup?: () => void;
onBlockContact?: () => void;
onMarkAllRead: () => void;
onCopyPublicKey?: () => void;
onUnblockContact?: () => void;
onInviteContacts?: () => void;
@ -48,6 +50,7 @@ export const ConversationListItemContextMenu = (
onBlockContact,
onClearNickname,
onCopyPublicKey,
onMarkAllRead,
onUnblockContact,
onInviteContacts,
onLeaveGroup,
@ -81,6 +84,8 @@ export const ConversationListItemContextMenu = (
onCopyPublicKey,
window.i18n
)}
{getMarkAllReadMenuItem(onMarkAllRead, window.i18n)}
{getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)}
{getInviteContactMenuItem(
type === 'group',

View File

@ -205,6 +205,13 @@ export function getCopyMenuItem(
return null;
}
export function getMarkAllReadMenuItem(
action: any,
i18n: LocalizerType
): JSX.Element | null {
return <Item onClick={action}>{i18n('markAllAsRead')}</Item>;
}
export function getDisappearingMenuItem(
isPublic: boolean | undefined,
isKickedFromGroup: boolean | undefined,

View File

@ -423,6 +423,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
onInviteContacts: () => {
window.Whisper.events.trigger('inviteContacts', this);
},
onMarkAllRead: () => {
void this.markReadBouncy(Date.now());
},
onClearNickname: () => {
void this.setLokiProfile({ displayName: null });
},
@ -468,7 +471,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
public async getUnreadCount() {
window.log.warn('getUnreadCount is slow');
const unreadCount = await getUnreadCountByConversation(this.id);
return unreadCount;

View File

@ -87,15 +87,16 @@ export interface ConversationType {
groupAdmins?: Array<string>; // admins for closed groups and moderators for open groups
members?: Array<string>; // members for closed groups only
onClick?: () => any;
onBlockContact?: () => any;
onUnblockContact?: () => any;
onCopyPublicKey?: () => any;
onDeleteContact?: () => any;
onLeaveGroup?: () => any;
onDeleteMessages?: () => any;
onInviteContacts?: () => any;
onClearNickname?: () => any;
onClick?: () => void;
onBlockContact?: () => void;
onUnblockContact?: () => void;
onCopyPublicKey?: () => void;
onDeleteContact?: () => void;
onLeaveGroup?: () => void;
onDeleteMessages?: () => void;
onInviteContacts?: () => void;
onMarkAllRead?: () => void;
onClearNickname?: () => void;
}
export type ConversationLookupType = {