2022-10-24 07:50:21 +01:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-10-24 07:50:21 +01:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-10-24 07:50:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2023-08-04 08:36:16 +01:00
|
|
|
import { Room } from "matrix-js-sdk/src/matrix";
|
2022-10-24 07:50:21 +01:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
import { useUnreadNotifications } from "../../../../hooks/useUnreadNotifications";
|
|
|
|
|
import { StatelessNotificationBadge } from "./StatelessNotificationBadge";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
2023-01-31 12:38:25 +00:00
|
|
|
room?: Room;
|
2022-10-24 07:50:21 +01:00
|
|
|
threadId?: string;
|
2024-03-14 14:30:47 +00:00
|
|
|
/**
|
|
|
|
|
* If true, where we would normally show a badge, we instead show a dot. No numeric count will
|
|
|
|
|
* be displayed.
|
|
|
|
|
*/
|
|
|
|
|
forceDot?: boolean;
|
2022-10-24 07:50:21 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-14 14:30:47 +00:00
|
|
|
export function UnreadNotificationBadge({ room, threadId, forceDot }: Props): JSX.Element {
|
2024-01-15 15:25:48 +00:00
|
|
|
const { symbol, count, level } = useUnreadNotifications(room, threadId);
|
2022-10-24 07:50:21 +01:00
|
|
|
|
2024-03-14 14:30:47 +00:00
|
|
|
return <StatelessNotificationBadge symbol={symbol} count={count} level={level} forceDot={forceDot} />;
|
2022-10-24 07:50:21 +01:00
|
|
|
}
|