Preliminary filter work on notifications

This commit is contained in:
Lim Chee Aun 2024-10-10 15:14:08 +08:00
parent a25bcba8a6
commit d5e985d6d4

View file

@ -4,6 +4,7 @@ import { Fragment } from 'preact';
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { api } from '../utils/api'; import { api } from '../utils/api';
import { isFiltered } from '../utils/filters';
import shortenNumber from '../utils/shorten-number'; import shortenNumber from '../utils/shorten-number';
import states, { statusKey } from '../utils/states'; import states, { statusKey } from '../utils/states';
import { getCurrentAccountID } from '../utils/store-utils'; import { getCurrentAccountID } from '../utils/store-utils';
@ -451,6 +452,16 @@ function Notification({
notificationsCount > 0 && notificationsCount > sampleAccounts?.length; notificationsCount > 0 && notificationsCount > sampleAccounts?.length;
const expandAccounts = diffCount ? 'remote' : 'local'; 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 ( return (
<div <div
class={`notification notification-${type}`} class={`notification notification-${type}`}