fix: run prettier
This commit is contained in:
@ -16,7 +16,7 @@ import type { Badge } from "types";
|
||||
|
||||
export function useBadges(
|
||||
pubkey: string,
|
||||
leaveOpen = true,
|
||||
leaveOpen = true
|
||||
): { badges: Badge[]; awards: TaggedRawEvent[] } {
|
||||
const since = useMemo(() => unixNow() - WEEK, [pubkey]);
|
||||
const rb = useMemo(() => {
|
||||
@ -33,7 +33,7 @@ export function useBadges(
|
||||
const { data: badgeEvents } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
rb,
|
||||
rb
|
||||
);
|
||||
|
||||
const rawBadges = useMemo(() => {
|
||||
@ -64,7 +64,7 @@ export function useBadges(
|
||||
const acceptedStream = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
acceptedSub,
|
||||
acceptedSub
|
||||
);
|
||||
const acceptedEvents = acceptedStream.data ?? [];
|
||||
|
||||
@ -73,18 +73,18 @@ export function useBadges(
|
||||
const name = findTag(e, "d") ?? "";
|
||||
const address = toAddress(e);
|
||||
const awardEvents = badgeAwards.filter(
|
||||
(b) => findTag(b, "a") === address,
|
||||
(b) => findTag(b, "a") === address
|
||||
);
|
||||
const awardees = new Set(
|
||||
awardEvents.map((e) => getTagValues(e.tags, "p")).flat(),
|
||||
awardEvents.map((e) => getTagValues(e.tags, "p")).flat()
|
||||
);
|
||||
const accepted = new Set(
|
||||
acceptedEvents
|
||||
.filter((pb) => awardees.has(pb.pubkey))
|
||||
.filter((pb) =>
|
||||
pb.tags.find((t) => t.at(0) === "a" && t.at(1) === address),
|
||||
pb.tags.find((t) => t.at(0) === "a" && t.at(1) === address)
|
||||
)
|
||||
.map((pb) => pb.pubkey),
|
||||
.map((pb) => pb.pubkey)
|
||||
);
|
||||
const thumb = findTag(e, "thumb");
|
||||
const image = findTag(e, "image");
|
||||
|
@ -15,13 +15,13 @@ import { System } from "index";
|
||||
export function useUserCards(
|
||||
pubkey: string,
|
||||
userCards: Array<string[]>,
|
||||
leaveOpen = false,
|
||||
leaveOpen = false
|
||||
): TaggedRawEvent[] {
|
||||
const related = useMemo(() => {
|
||||
// filtering to only show CARD kinds for now, but in the future we could link and render anything
|
||||
if (userCards?.length > 0) {
|
||||
return userCards.filter(
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`),
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`)
|
||||
);
|
||||
}
|
||||
return [];
|
||||
@ -52,7 +52,7 @@ export function useUserCards(
|
||||
const { data } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
subRelated,
|
||||
subRelated
|
||||
);
|
||||
|
||||
const cards = useMemo(() => {
|
||||
@ -64,7 +64,7 @@ export function useUserCards(
|
||||
(e) =>
|
||||
e.kind === kind &&
|
||||
e.pubkey === pubkey &&
|
||||
findTag(e, "d") === identifier,
|
||||
findTag(e, "d") === identifier
|
||||
);
|
||||
})
|
||||
.filter((e) => e)
|
||||
@ -89,14 +89,14 @@ export function useCards(pubkey: string, leaveOpen = false): TaggedRawEvent[] {
|
||||
const { data: userCards } = useRequestBuilder<ReplaceableNoteStore>(
|
||||
System,
|
||||
ReplaceableNoteStore,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
const related = useMemo(() => {
|
||||
// filtering to only show CARD kinds for now, but in the future we could link and render anything
|
||||
if (userCards) {
|
||||
return userCards.tags.filter(
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`),
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${CARD}:`)
|
||||
);
|
||||
}
|
||||
return [];
|
||||
@ -127,7 +127,7 @@ export function useCards(pubkey: string, leaveOpen = false): TaggedRawEvent[] {
|
||||
const { data } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
subRelated,
|
||||
subRelated
|
||||
);
|
||||
const cardEvents = data ?? [];
|
||||
|
||||
@ -140,7 +140,7 @@ export function useCards(pubkey: string, leaveOpen = false): TaggedRawEvent[] {
|
||||
(e) =>
|
||||
e.kind === kind &&
|
||||
e.pubkey === pubkey &&
|
||||
findTag(e, "d") === identifier,
|
||||
findTag(e, "d") === identifier
|
||||
);
|
||||
})
|
||||
.filter((e) => e)
|
||||
|
@ -37,7 +37,7 @@ export function useUserEmojiPacks(pubkey?: string, userEmoji?: Tags) {
|
||||
const related = useMemo(() => {
|
||||
if (userEmoji) {
|
||||
return userEmoji?.filter(
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${EMOJI_PACK}:`),
|
||||
(t) => t.at(0) === "a" && t.at(1)?.startsWith(`${EMOJI_PACK}:`)
|
||||
);
|
||||
}
|
||||
return [];
|
||||
@ -67,7 +67,7 @@ export function useUserEmojiPacks(pubkey?: string, userEmoji?: Tags) {
|
||||
const { data: relatedData } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
subRelated,
|
||||
subRelated
|
||||
);
|
||||
|
||||
const emojiPacks = useMemo(() => {
|
||||
@ -95,7 +95,7 @@ export default function useEmoji(pubkey?: string) {
|
||||
const { data: userEmoji } = useRequestBuilder<ReplaceableNoteStore>(
|
||||
System,
|
||||
ReplaceableNoteStore,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
const emojis = useUserEmojiPacks(pubkey, userEmoji?.tags ?? []);
|
||||
|
@ -20,7 +20,7 @@ export function useAddress(kind: number, pubkey: string, identifier: string) {
|
||||
const { data } = useRequestBuilder<ReplaceableNoteStore>(
|
||||
System,
|
||||
ReplaceableNoteStore,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
return data;
|
||||
@ -52,7 +52,7 @@ export function useEvent(link: NostrLink) {
|
||||
const { data } = useRequestBuilder<ReplaceableNoteStore>(
|
||||
System,
|
||||
ReplaceableNoteStore,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
return data;
|
||||
|
@ -26,10 +26,14 @@ export function useZaps(goal: NostrEvent, leaveOpen = false) {
|
||||
const { data } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
return data?.map((ev) => parseZap(ev, System.ProfileLoader.Cache)).filter((z) => z && z.valid) ?? [];
|
||||
return (
|
||||
data
|
||||
?.map((ev) => parseZap(ev, System.ProfileLoader.Cache))
|
||||
.filter((z) => z && z.valid) ?? []
|
||||
);
|
||||
}
|
||||
|
||||
export function useZapGoal(host: string, link: NostrLink, leaveOpen = false) {
|
||||
@ -46,7 +50,7 @@ export function useZapGoal(host: string, link: NostrLink, leaveOpen = false) {
|
||||
const { data } = useRequestBuilder<ReplaceableNoteStore>(
|
||||
System,
|
||||
ReplaceableNoteStore,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
return data;
|
||||
|
@ -55,7 +55,7 @@ export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>) {
|
||||
const reactionsSub = useRequestBuilder<FlatNoteStore>(
|
||||
System,
|
||||
FlatNoteStore,
|
||||
esub,
|
||||
esub
|
||||
);
|
||||
|
||||
const reactions = reactionsSub.data ?? [];
|
||||
|
@ -43,10 +43,10 @@ export function useStreamsFeed(tag?: string) {
|
||||
}, [feed.data]);
|
||||
|
||||
const live = feedSorted.filter(
|
||||
(a) => findTag(a, "status") === StreamState.Live,
|
||||
(a) => findTag(a, "status") === StreamState.Live
|
||||
);
|
||||
const planned = feedSorted.filter(
|
||||
(a) => findTag(a, "status") === StreamState.Planned,
|
||||
(a) => findTag(a, "status") === StreamState.Planned
|
||||
);
|
||||
const ended = feedSorted.filter((a) => {
|
||||
const hasEnded = findTag(a, "status") === StreamState.Ended;
|
||||
|
@ -12,7 +12,7 @@ import { getPublisher } from "login";
|
||||
export function useLogin() {
|
||||
const session = useSyncExternalStore(
|
||||
(c) => Login.hook(c),
|
||||
() => Login.snapshot(),
|
||||
() => Login.snapshot()
|
||||
);
|
||||
if (!session) return;
|
||||
return {
|
||||
@ -27,7 +27,7 @@ export function useLoginEvents(pubkey?: string, leaveOpen = false) {
|
||||
const [userEmojis, setUserEmojis] = useState<Tags>([]);
|
||||
const session = useSyncExternalStore(
|
||||
(c) => Login.hook(c),
|
||||
() => Login.snapshot(),
|
||||
() => Login.snapshot()
|
||||
);
|
||||
|
||||
const sub = useMemo(() => {
|
||||
@ -45,7 +45,7 @@ export function useLoginEvents(pubkey?: string, leaveOpen = false) {
|
||||
const { data } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
sub,
|
||||
sub
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -27,12 +27,11 @@ export function useProfile(link: NostrLink, leaveOpen = false) {
|
||||
return b;
|
||||
}, [link, leaveOpen]);
|
||||
|
||||
const { data: streamsData } =
|
||||
useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
sub
|
||||
);
|
||||
const { data: streamsData } = useRequestBuilder<NoteCollection>(
|
||||
System,
|
||||
NoteCollection,
|
||||
sub
|
||||
);
|
||||
const streams = streamsData ?? [];
|
||||
|
||||
const addresses = useMemo(() => {
|
||||
|
@ -2,5 +2,8 @@ import { StreamProviderStore } from "providers";
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
export function useStreamProvider() {
|
||||
return useSyncExternalStore(c => StreamProviderStore.hook(c), () => StreamProviderStore.snapshot());
|
||||
}
|
||||
return useSyncExternalStore(
|
||||
(c) => StreamProviderStore.hook(c),
|
||||
() => StreamProviderStore.snapshot()
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user