refactor: clean up
This commit is contained in:
parent
a500c040f9
commit
ba2fde425f
@ -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) {
|
||||
|
@ -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<RootState, [HexKey | undefined, number, HexKey[]]>(s => [s.login.publicKey, s.login.readNotifications, s.login.muted]);
|
||||
const { isMuted } = useModeration();
|
||||
const [pubKey, readNotifications] = useSelector<RootState, [HexKey | undefined, number]>(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)) {
|
||||
|
@ -483,7 +483,3 @@ body.scroll-lock {
|
||||
.bold {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.blurred {
|
||||
filter: blur(5px);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user