Skip to content

Commit

Permalink
Add an action panel button to mark all conversations as read.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmacd committed Feb 23, 2023
1 parent 2710ea9 commit f915896
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"debugLogExplanation": "This log will be saved to your desktop.",
"reportIssue": "Report a Bug",
"markAllAsRead": "Mark All as Read",
"allMarkedAsRead": "All conversations marked read.",
"incomingError": "Error handling incoming message",
"media": "Media",
"mediaEmptyState": "No media",
Expand Down
3 changes: 3 additions & 0 deletions ts/components/icon/SessionIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface SProps extends SessionIconProps {
dataTestId?: string;
id?: string;
style?: object;
title?: string;
}

const StyledSessionIconButton = styled.div<{ color?: string; isSelected?: boolean }>`
Expand Down Expand Up @@ -55,6 +56,7 @@ const SessionIconButtonInner = React.forwardRef<HTMLDivElement, SProps>((props,
id,
dataTestId,
style,
title
} = props;
const clickHandler = (e: React.MouseEvent<HTMLDivElement>) => {
if (props.onClick) {
Expand All @@ -65,6 +67,7 @@ const SessionIconButtonInner = React.forwardRef<HTMLDivElement, SProps>((props,

return (
<StyledSessionIconButton
title={title}
color={iconColor}
isSelected={isSelected}
className={classNames('session-icon-button', iconSize)}
Expand Down
21 changes: 21 additions & 0 deletions ts/components/leftpane/ActionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ const Section = (props: { type: SectionType }) => {
} else if (type === SectionType.PathIndicator) {
// Show Path Indicator Modal
dispatch(onionPathModal({}));
} else if (type === SectionType.MarkAllAsRead) {
const controller = getConversationController();
const convos = controller.getConversations().filter(conversation => {
return conversation.isApproved();
});
for (const convo of convos) {
await controller.get(convo.id).markAllAsRead();
}
ToastUtils.pushToastSuccess('allMarkedRead', window.i18n('allMarkedAsRead'));
} else {
// message section
dispatch(clearSearch());
Expand Down Expand Up @@ -111,6 +120,17 @@ const Section = (props: { type: SectionType }) => {
isSelected={isSelected}
/>
);
case SectionType.MarkAllAsRead:
return (
<SessionIconButton
title={window.i18n('markAllAsRead')}
iconSize="medium"
dataTestId="markallasread-section"
iconType={'check'}
onClick={handleClick}
isSelected={isSelected}
/>
);
case SectionType.Settings:
return (
<SessionIconButton
Expand Down Expand Up @@ -287,6 +307,7 @@ export const ActionsPanel = () => {
<LeftPaneSectionContainer data-testid="leftpane-section-container">
<Section type={SectionType.Profile} />
<Section type={SectionType.Message} />
<Section type={SectionType.MarkAllAsRead} />
<Section type={SectionType.Settings} />

<Section type={SectionType.PathIndicator} />
Expand Down
1 change: 1 addition & 0 deletions ts/state/ducks/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum SectionType {
Profile,
Message,
Settings,
MarkAllAsRead,
ColorMode,
PathIndicator,
}
Expand Down
1 change: 1 addition & 0 deletions ts/types/LocalizerKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export type LocalizerKeys =
| 'cannotRemoveCreatorFromGroup'
| 'editMenuCut'
| 'markAllAsRead'
| 'allMarkedAsRead'
| 'failedResolveOns'
| 'showDebugLog'
| 'declineRequestMessage'
Expand Down

0 comments on commit f915896

Please sign in to comment.