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

Make empty state copy for TAC depend on the value of the setting #12419

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* /
*/

import React, { JSX, useState } from "react";
import React, { JSX, useCallback, useState } from "react";
import { Menu, MenuItem } from "@vector-im/compound-web";
import { Room } from "matrix-js-sdk/src/matrix";

Expand All @@ -36,6 +36,7 @@ import { getKeyBindingsManager } from "../../../../KeyBindingsManager";
import { KeyBindingAction } from "../../../../accessibility/KeyboardShortcuts";
import { ReleaseAnnouncement } from "../../../structures/ReleaseAnnouncement";
import { useIsReleaseAnnouncementOpen } from "../../../../hooks/useIsReleaseAnnouncementOpen";
import { useSettingValue } from "../../../../hooks/useSettings";

interface ThreadsActivityCentreProps {
/**
Expand All @@ -52,6 +53,15 @@ export function ThreadsActivityCentre({ displayButtonLabel }: ThreadsActivityCen
const [open, setOpen] = useState(false);
const roomsAndNotifications = useUnreadThreadRooms(open);
const isReleaseAnnouncementOpen = useIsReleaseAnnouncementOpen("threadsActivityCentre");
const settingTACOnlyNotifs = useSettingValue<boolean>("Notifications.tac_only_notifications");

const emptyCaption = useCallback((): string => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of useCallback seems too much for me in this use case.
A simple ternary/if is enough I think

if (settingTACOnlyNotifs) {
return _t("threads_activity_centre|no_rooms_with_threads_notifs");
} else {
return _t("threads_activity_centre|no_rooms_with_unread_threads");
}
}, [settingTACOnlyNotifs]);

return (
<div
Expand Down Expand Up @@ -110,9 +120,7 @@ export function ThreadsActivityCentre({ displayButtonLabel }: ThreadsActivityCen
/>
))}
{roomsAndNotifications.rooms.length === 0 && (
<div className="mx_ThreadsActivityCentre_emptyCaption">
{_t("threads_activity_centre|no_rooms_with_unreads_threads")}
</div>
<div className="mx_ThreadsActivityCentre_emptyCaption">{emptyCaption()}</div>
)}
</div>
</Menu>
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,8 @@
},
"threads_activity_centre": {
"header": "Threads activity",
"no_rooms_with_unreads_threads": "You don't have rooms with unread threads yet.",
"no_rooms_with_threads_notifs": "You don't have rooms with thread notifications yet.",
"no_rooms_with_unread_threads": "You don't have rooms with unread threads yet.",
"release_announcement_description": "Threads notifications have moved, find them here from now on.",
"release_announcement_header": "Threads Activity Centre"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ exports[`ThreadsActivityCentre should match snapshot when empty 1`] = `
<div
class="mx_ThreadsActivityCentre_emptyCaption"
>
You don't have rooms with unread threads yet.
You don't have rooms with thread notifications yet.
</div>
</div>
</div>
Expand Down
Loading