forked from Kieran/snort
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 Note from "Element/Note";
|
||||||
import NoteReaction from "Element/NoteReaction";
|
import NoteReaction from "Element/NoteReaction";
|
||||||
import type { RootState } from "State/Store";
|
import type { RootState } from "State/Store";
|
||||||
|
import useModeration from "Hooks/useModeration";
|
||||||
|
|
||||||
export interface TimelineProps {
|
export interface TimelineProps {
|
||||||
postsOnly: boolean,
|
postsOnly: boolean,
|
||||||
@ -22,13 +23,13 @@ export interface TimelineProps {
|
|||||||
* A list of notes by pubkeys
|
* A list of notes by pubkeys
|
||||||
*/
|
*/
|
||||||
export default function Timeline({ subject, postsOnly = false, method }: TimelineProps) {
|
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, {
|
const { main, related, latest, parent, loadMore, showLatest } = useTimelineFeed(subject, {
|
||||||
method
|
method
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterPosts = useCallback((nts: TaggedRawEvent[]) => {
|
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]);
|
}, [postsOnly, muted]);
|
||||||
|
|
||||||
const mainFeed = useMemo(() => {
|
const mainFeed = useMemo(() => {
|
||||||
@ -37,7 +38,7 @@ export default function Timeline({ subject, postsOnly = false, method }: Timelin
|
|||||||
|
|
||||||
const latestFeed = useMemo(() => {
|
const latestFeed = useMemo(() => {
|
||||||
return filterPosts(latest.notes).filter(a => !mainFeed.some(b => b.id === a.id))
|
return filterPosts(latest.notes).filter(a => !mainFeed.some(b => b.id === a.id))
|
||||||
}, [latest, mainFeed, filterPosts, muted]);
|
}, [latest, mainFeed, filterPosts]);
|
||||||
|
|
||||||
function eventElement(e: TaggedRawEvent) {
|
function eventElement(e: TaggedRawEvent) {
|
||||||
switch (e.kind) {
|
switch (e.kind) {
|
||||||
|
@ -12,6 +12,7 @@ import useSubscription from "Feed/Subscription";
|
|||||||
import { MUTE_LIST_TAG, getMutedKeys } from "Feed/MuteList";
|
import { MUTE_LIST_TAG, getMutedKeys } from "Feed/MuteList";
|
||||||
import { mapEventToProfile, MetadataCache } from "Db/User";
|
import { mapEventToProfile, MetadataCache } from "Db/User";
|
||||||
import { getDisplayName } from "Element/ProfileImage";
|
import { getDisplayName } from "Element/ProfileImage";
|
||||||
|
import useModeration from "Hooks/useModeration";
|
||||||
import { MentionRegex } from "Const";
|
import { MentionRegex } from "Const";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +20,8 @@ import { MentionRegex } from "Const";
|
|||||||
*/
|
*/
|
||||||
export default function useLoginFeed() {
|
export default function useLoginFeed() {
|
||||||
const dispatch = useDispatch();
|
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(() => {
|
const subMetadata = useMemo(() => {
|
||||||
if (!pubKey) return null;
|
if (!pubKey) return null;
|
||||||
@ -112,7 +114,7 @@ export default function useLoginFeed() {
|
|||||||
}, [metadataFeed.store]);
|
}, [metadataFeed.store]);
|
||||||
|
|
||||||
useEffect(() => {
|
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") {
|
if ("Notification" in window && Notification.permission === "granted") {
|
||||||
for (let nx of notifications.filter(a => (a.created_at * 1000) > readNotifications)) {
|
for (let nx of notifications.filter(a => (a.created_at * 1000) > readNotifications)) {
|
||||||
|
@ -483,7 +483,3 @@ body.scroll-lock {
|
|||||||
.bold {
|
.bold {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blurred {
|
|
||||||
filter: blur(5px);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user