From ba2fde425faf072a1f3f46d99cae1759e3adab3f Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Fri, 27 Jan 2023 08:21:48 +0100 Subject: [PATCH] refactor: clean up --- src/Element/Timeline.tsx | 7 ++++--- src/Feed/LoginFeed.ts | 6 ++++-- src/index.css | 4 ---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Element/Timeline.tsx b/src/Element/Timeline.tsx index 447b06cb..2e95feb9 100644 --- a/src/Element/Timeline.tsx +++ b/src/Element/Timeline.tsx @@ -11,6 +11,7 @@ import LoadMore from "Element/LoadMore"; import Note from "Element/Note"; import NoteReaction from "Element/NoteReaction"; import type { RootState } from "State/Store"; +import useModeration from "Hooks/useModeration"; export interface TimelineProps { postsOnly: boolean, @@ -22,13 +23,13 @@ export interface TimelineProps { * A list of notes by pubkeys */ export default function Timeline({ subject, postsOnly = false, method }: TimelineProps) { - const muted = useSelector((s: RootState) => s.login.muted) + const { muted, isMuted } = useModeration(); const { main, related, latest, parent, loadMore, showLatest } = useTimelineFeed(subject, { method }); const filterPosts = useCallback((nts: TaggedRawEvent[]) => { - return [...nts].sort((a, b) => b.created_at - a.created_at)?.filter(a => postsOnly ? !a.tags.some(b => b[0] === "e") : true).filter(a => !muted.includes(a.pubkey)); + return [...nts].sort((a, b) => b.created_at - a.created_at)?.filter(a => postsOnly ? !a.tags.some(b => b[0] === "e") : true).filter(a => !isMuted(a.pubkey)); }, [postsOnly, muted]); const mainFeed = useMemo(() => { @@ -37,7 +38,7 @@ export default function Timeline({ subject, postsOnly = false, method }: Timelin const latestFeed = useMemo(() => { return filterPosts(latest.notes).filter(a => !mainFeed.some(b => b.id === a.id)) - }, [latest, mainFeed, filterPosts, muted]); + }, [latest, mainFeed, filterPosts]); function eventElement(e: TaggedRawEvent) { switch (e.kind) { diff --git a/src/Feed/LoginFeed.ts b/src/Feed/LoginFeed.ts index 7a762451..9ca50ffc 100644 --- a/src/Feed/LoginFeed.ts +++ b/src/Feed/LoginFeed.ts @@ -12,6 +12,7 @@ import useSubscription from "Feed/Subscription"; import { MUTE_LIST_TAG, getMutedKeys } from "Feed/MuteList"; import { mapEventToProfile, MetadataCache } from "Db/User"; import { getDisplayName } from "Element/ProfileImage"; +import useModeration from "Hooks/useModeration"; import { MentionRegex } from "Const"; /** @@ -19,7 +20,8 @@ import { MentionRegex } from "Const"; */ export default function useLoginFeed() { const dispatch = useDispatch(); - const [pubKey, readNotifications, muted] = useSelector(s => [s.login.publicKey, s.login.readNotifications, s.login.muted]); + const { isMuted } = useModeration(); + const [pubKey, readNotifications] = useSelector(s => [s.login.publicKey, s.login.readNotifications]); const subMetadata = useMemo(() => { if (!pubKey) return null; @@ -112,7 +114,7 @@ export default function useLoginFeed() { }, [metadataFeed.store]); useEffect(() => { - let notifications = notificationFeed.store.notes.filter(a => a.kind === EventKind.TextNote && !muted.includes(a.pubkey)) + let notifications = notificationFeed.store.notes.filter(a => a.kind === EventKind.TextNote && !isMuted(a.pubkey)) if ("Notification" in window && Notification.permission === "granted") { for (let nx of notifications.filter(a => (a.created_at * 1000) > readNotifications)) { diff --git a/src/index.css b/src/index.css index 81aefb4f..f6b76757 100644 --- a/src/index.css +++ b/src/index.css @@ -483,7 +483,3 @@ body.scroll-lock { .bold { font-weight: 700; } - -.blurred { - filter: blur(5px); -}