Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Use the StatelessNotificationBadge component in ThreadsActivityCentre #12167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions res/css/structures/_ThreadsActivityCentre.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,3 @@
}
}
}

.mx_ThreadsActivityCentreBadge {
background-color: $primary-content;
width: 8px;
height: 8px;
border-radius: 8px;

&.mx_ThreadsActivityCentreBadge_highlight {
background-color: $alert;
}

&.mx_ThreadsActivityCentreBadge_normal {
background-color: var(--cpd-color-icon-accent-tertiary);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import { Action } from "../../../../dispatcher/actions";
import defaultDispatcher from "../../../../dispatcher/dispatcher";
import { ViewRoomPayload } from "../../../../dispatcher/payloads/ViewRoomPayload";
import { ThreadsActivityCentreBadge, ThreadsActivityNotificationState } from "./ThreadsActivityCentreBadge";
import RightPanelStore from "../../../../stores/right-panel/RightPanelStore";
import { RightPanelPhases } from "../../../../stores/right-panel/RightPanelStorePhases";
import { useUnreadThreadRooms } from "./useUnreadThreadRooms";
import { StatelessNotificationBadge } from "../../rooms/NotificationBadge/StatelessNotificationBadge";
import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel";

interface ThreadsActivityCentreProps {
/**
Expand Down Expand Up @@ -57,11 +58,11 @@
>
{/* Make the content of the pop-up scrollable */}
<div className="mx_ThreadsActivity_rows">
{roomsAndNotifications.map(({ room, notificationState }) => (
{roomsAndNotifications.map(({ room, notificationLevel }) => (
<ThreadsActivityRow
key={room.roomId}
room={room}
notificationState={notificationState}
notificationLevel={notificationLevel}
onClick={() => setOpen(false)}
/>
))}
Expand All @@ -78,7 +79,7 @@
/**
* The state of the badge.
*/
notificationState: ThreadsActivityNotificationState;
notificationLevel: NotificationLevel;
/**
* Callback when the user clicks on the row.
*/
Expand All @@ -88,7 +89,7 @@
/**
* Display a room with unread threads.
*/
function ThreadsActivityRow({ room, onClick, notificationState }: ThreadsActivityRow): JSX.Element {
function ThreadsActivityRow({ room, onClick, notificationLevel }: ThreadsActivityRow): JSX.Element {
return (
<MenuItem
className="mx_ThreadsActivityRow"
Expand All @@ -109,9 +110,9 @@
});
}}
label={room.name}
Icon={<DecoratedRoomAvatar room={room} size="32px" />}

Check failure on line 113 in src/components/views/spaces/threads-activity-centre/ThreadsActivityCentre.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Type 'Element' is not assignable to type 'ComponentType<SVGAttributes<SVGElement>>'.
>
<ThreadsActivityCentreBadge state={notificationState} />
<StatelessNotificationBadge level={notificationLevel} count={0} symbol={null} type="dot" />
</MenuItem>
);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
import { useMemo } from "react";
import { NotificationCountType, Room } from "matrix-js-sdk/src/matrix";

import { ThreadsActivityNotificationState } from "./ThreadsActivityCentreBadge";
import RoomListStore from "../../../../stores/room-list/RoomListStore";
import { doesRoomHaveUnreadThreads } from "../../../../Unread";
import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel";

/**
* TODO doc
* @param open
*/
export function useUnreadThreadRooms(
open: boolean,
): Array<{ room: Room; notificationState: ThreadsActivityNotificationState }> {
export function useUnreadThreadRooms(open: boolean): Array<{ room: Room; notificationLevel: NotificationLevel }> {
return useMemo(() => {
if (!open) return [];

Expand All @@ -39,22 +37,22 @@ export function useUnreadThreadRooms(
return acc;
}, [])
.filter((room) => doesRoomHaveUnreadThreads(room))
.map((room) => ({ room, notificationState: getNotificationState(room) }));
.map((room) => ({ room, notificationLevel: getNotificationState(room) }));
}, [open]);
}

/**
* TODO doc
* @param room
*/
function getNotificationState(room: Room): ThreadsActivityNotificationState {
function getNotificationState(room: Room): NotificationLevel {
const notificationCountType = room.threadsAggregateNotificationType;
switch (notificationCountType) {
case NotificationCountType.Highlight:
return "highlight";
return NotificationLevel.Highlight;
case NotificationCountType.Total:
return "normal";
return NotificationLevel.Notification;
default:
return "minor";
return NotificationLevel.Activity;
}
}
Loading