forked from Kieran/snort
stop the upstream events when the low-data-mode is on
This commit is contained in:
parent
0ff8199896
commit
a41a51e6ab
@ -39,8 +39,13 @@ export function NoteInner(props: NoteProps) {
|
||||
|
||||
const { isEventMuted } = useModeration();
|
||||
const { ref, inView } = useInView({ triggerOnce: true, rootMargin: "2000px" });
|
||||
const { reactions, reposts, deletions, zaps } = useEventReactions(NostrLink.fromEvent(ev), related);
|
||||
const login = useLogin();
|
||||
const { preferences } = useLogin(s => ({ preferences: s.appData.item.preferences }));
|
||||
const { reactions, reposts, deletions, zaps } = preferences.lowDataMode? {reactions:{
|
||||
all: [],
|
||||
positive: [],
|
||||
negative: [],
|
||||
}, reposts:[], deletions:[], zaps:[]} : useEventReactions(NostrLink.fromEvent(ev), related);
|
||||
const { pinned, bookmarked } = useLogin();
|
||||
const { publisher, system } = useEventPublisher();
|
||||
const [translated, setTranslated] = useState<NoteTranslation>();
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { EventKind, NostrLink, RequestBuilder, NoteCollection, EventExt } from "@snort/system";
|
||||
import { useReactions, useRequestBuilder } from "@snort/system-react";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
|
||||
export default function useThreadFeed(link: NostrLink) {
|
||||
const [root, setRoot] = useState<NostrLink>();
|
||||
const [allEvents, setAllEvents] = useState<Array<NostrLink>>([]);
|
||||
const { preferences } = useLogin(s => ({ preferences: s.appData.item.preferences }));
|
||||
|
||||
const sub = useMemo(() => {
|
||||
const sub = new RequestBuilder(`thread:${link.id.slice(0, 12)}`);
|
||||
@ -62,7 +64,7 @@ export default function useThreadFeed(link: NostrLink) {
|
||||
}
|
||||
}, [store.data?.length]);
|
||||
|
||||
const reactions = useReactions(`thread:${link.id.slice(0, 12)}:reactions`, [link, ...allEvents]);
|
||||
const reactions = preferences.lowDataMode ? [] :useReactions(`thread:${link.id.slice(0, 12)}:reactions`, [link, ...allEvents]);
|
||||
|
||||
return {
|
||||
thread: store.data ?? [],
|
||||
|
@ -131,7 +131,7 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
|
||||
}, [pref.autoShowLatest, createBuilder]);
|
||||
|
||||
const latest = useRequestBuilder(NoteCollection, subRealtime);
|
||||
const reactions = useReactions(`${sub?.id}-reactions`, main.data?.map(a => NostrLink.fromEvent(a)) ?? []);
|
||||
const reactions = pref.lowDataMode? [] : useReactions(`${sub?.id}-reactions`, main.data?.map(a => NostrLink.fromEvent(a)) ?? []);
|
||||
|
||||
return {
|
||||
main: main.data,
|
||||
|
@ -5,6 +5,7 @@ import useThreadFeed from "@/Feed/ThreadFeed";
|
||||
import { ReactNode, createContext, useMemo, useState } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import useModeration from "./useModeration";
|
||||
import useLogin from "./useLogin";
|
||||
|
||||
export interface ThreadContext {
|
||||
current: string;
|
||||
@ -38,6 +39,7 @@ export function ThreadContextWrapper({ link, children }: { link: NostrLink; chil
|
||||
const [currentId, setCurrentId] = useState(unwrap(link.toEventTag())[1]);
|
||||
const feed = useThreadFeed(link);
|
||||
const { isBlocked } = useModeration();
|
||||
const { preferences } = useLogin(s => ({ preferences: s.appData.item.preferences }));
|
||||
|
||||
const chains = useMemo(() => {
|
||||
const chains = new Map<u256, Array<TaggedNostrEvent>>();
|
||||
@ -79,7 +81,7 @@ export function ThreadContextWrapper({ link, children }: { link: NostrLink; chil
|
||||
current: currentId,
|
||||
root,
|
||||
chains,
|
||||
reactions: feed.reactions,
|
||||
reactions: preferences.lowDataMode? [] : feed.reactions,
|
||||
data: feed.thread,
|
||||
setCurrent: v => setCurrentId(v),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user