From d5e985d6d43cf986faeb9e1f076242e75db3f883 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 10 Oct 2024 15:14:08 +0800 Subject: [PATCH] Preliminary filter work on notifications --- src/components/notification.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/notification.jsx b/src/components/notification.jsx index 2ce66292..dc864bbf 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -4,6 +4,7 @@ import { Fragment } from 'preact'; import { memo } from 'preact/compat'; import { api } from '../utils/api'; +import { isFiltered } from '../utils/filters'; import shortenNumber from '../utils/shorten-number'; import states, { statusKey } from '../utils/states'; import { getCurrentAccountID } from '../utils/store-utils'; @@ -451,6 +452,16 @@ function Notification({ notificationsCount > 0 && notificationsCount > sampleAccounts?.length; const expandAccounts = diffCount ? 'remote' : 'local'; + // If there's a status and filter action is 'hide', then the notification is hidden + // TODO: Handle 'warn' action one day + if (!!status?.filtered) { + const isOwnPost = status?.account?.id === currentAccount; + const filterInfo = isFiltered(status.filtered, 'notifications'); + if (!isSelf && !isOwnPost && filterInfo?.action === 'hide') { + return null; + } + } + return (