From ae264dc19cd089981398c2575d555472d9f0f30a Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal Date: Wed, 27 Sep 2023 14:07:37 +0530 Subject: [PATCH 1/2] add show unread filter button --- .../Notifications/NotificationsList.tsx | 73 +++++++++++++------ src/Locale/en/Notifications.json | 2 + 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/Components/Notifications/NotificationsList.tsx b/src/Components/Notifications/NotificationsList.tsx index f6afa6cccd8..fa4ae75e32f 100644 --- a/src/Components/Notifications/NotificationsList.tsx +++ b/src/Components/Notifications/NotificationsList.tsx @@ -165,6 +165,7 @@ export default function NotificationsList({ const [isMarkingAllAsRead, setIsMarkingAllAsRead] = useState(false); const [isSubscribed, setIsSubscribed] = useState(""); const [isSubscribing, setIsSubscribing] = useState(false); + const [showUnread, setShowUnread] = useState(false); const { t } = useTranslation(); useEffect(() => { @@ -351,33 +352,46 @@ export default function NotificationsList({ } else if (data?.length) { manageResults = ( <> - {data.map((result: any) => ( - - ))} + {showUnread + ? data + .filter((notification: any) => notification.read_at === null) + .map((result: any) => ( + + )) + : data.map((result: any) => ( + + ))} {isLoading && (
)} - {totalCount > RESULT_LIMIT && offset < totalCount - RESULT_LIMIT && ( -
- setOffset((prev) => prev + RESULT_LIMIT)} - > - {isLoading ? t("loading") : t("load_more")} - -
- )} + {!showUnread && + totalCount > RESULT_LIMIT && + offset < totalCount - RESULT_LIMIT && ( +
+ setOffset((prev) => prev + RESULT_LIMIT)} + > + {isLoading ? t("loading") : t("load_more")} + +
+ )} ); } else if (data && data.length === 0) { @@ -448,6 +462,21 @@ export default function NotificationsList({ /> {t("mark_all_as_read")} + setShowUnread(!showUnread)} + > + + + + {showUnread + ? t("show_all_notifications") + : t("show_unread_notifications")} + + Date: Wed, 4 Oct 2023 19:29:00 +0530 Subject: [PATCH 2/2] refactor Co-authored-by: Khavin Shankar --- .../Notifications/NotificationsList.tsx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Components/Notifications/NotificationsList.tsx b/src/Components/Notifications/NotificationsList.tsx index fa4ae75e32f..5e3aa65b3ec 100644 --- a/src/Components/Notifications/NotificationsList.tsx +++ b/src/Components/Notifications/NotificationsList.tsx @@ -352,9 +352,8 @@ export default function NotificationsList({ } else if (data?.length) { manageResults = ( <> - {showUnread - ? data - .filter((notification: any) => notification.read_at === null) + {data + .filter((notification: any) => showUnread ? notification.read_at === null : true) .map((result: any) => ( - )) - : data.map((result: any) => ( - - ))} + ))} {isLoading && (