From 701a309a625a3417586e980f69ea7874adc397f3 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Wed, 18 Oct 2023 10:53:08 -0500 Subject: [PATCH] fix build --- src/components/magic-textarea.tsx | 4 +- .../post-modal/zap-split-creator.tsx | 6 +- src/components/search-modal/index.tsx | 4 +- src/providers/index.tsx | 6 +- src/providers/user-directory-provider.tsx | 20 ++-- src/views/note/components/reply-form.tsx | 95 +++++++++---------- src/views/streams/stream/index.tsx | 26 ++--- 7 files changed, 77 insertions(+), 84 deletions(-) diff --git a/src/components/magic-textarea.tsx b/src/components/magic-textarea.tsx index 42f3b5b44..a804c5054 100644 --- a/src/components/magic-textarea.tsx +++ b/src/components/magic-textarea.tsx @@ -10,7 +10,7 @@ import { nip19 } from "nostr-tools"; import { matchSorter } from "match-sorter/dist/match-sorter.esm.js"; import { Emoji, useContextEmojis } from "../providers/emoji-provider"; -import { useUserDirectoryContext } from "../providers/user-directory-provider"; +import { useUserSearchDirectoryContext } from "../providers/user-directory-provider"; import { UserAvatar } from "./user-avatar"; export type PeopleToken = { pubkey: string; names: string[] }; @@ -57,7 +57,7 @@ const Loading: ReactTextareaAutocompleteProps< function useAutocompleteTriggers() { const emojis = useContextEmojis(); - const getDirectory = useUserDirectoryContext(); + const getDirectory = useUserSearchDirectoryContext(); const triggers: TriggerType = { ":": { diff --git a/src/components/post-modal/zap-split-creator.tsx b/src/components/post-modal/zap-split-creator.tsx index 8a9e2ca46..bc5adab3b 100644 --- a/src/components/post-modal/zap-split-creator.tsx +++ b/src/components/post-modal/zap-split-creator.tsx @@ -17,7 +17,7 @@ import { useForm } from "react-hook-form"; import { EventSplit } from "../../helpers/nostr/zaps"; import { AddIcon } from "../icons"; -import { useUserDirectoryContext } from "../../providers/user-directory-provider"; +import { useUserSearchDirectoryContext } from "../../providers/user-directory-provider"; import { useAsync } from "react-use"; import { getUserDisplayName } from "../../helpers/user-metadata"; import userMetadataService from "../../services/user-metadata"; @@ -58,10 +58,10 @@ function AddUserForm({ }); watch("percent"); - const getDirectory = useUserDirectoryContext(); + const getDirectory = useUserSearchDirectoryContext(); const { value: users } = useAsync(async () => { const dir = await getDirectory(); - return dir.map((pubkey) => ({ pubkey, metadata: userMetadataService.getSubject(pubkey).value })); + return dir.map(({ pubkey }) => ({ pubkey, metadata: userMetadataService.getSubject(pubkey).value })); }, [getDirectory]); const submit = handleSubmit((values) => { diff --git a/src/components/search-modal/index.tsx b/src/components/search-modal/index.tsx index e590a773e..5de887eb8 100644 --- a/src/components/search-modal/index.tsx +++ b/src/components/search-modal/index.tsx @@ -5,7 +5,7 @@ import { useAsync, useThrottle } from "react-use"; import { matchSorter } from "match-sorter"; import { nip19 } from "nostr-tools"; -import { useUserDirectoryContext } from "../../providers/user-directory-provider"; +import { useUserSearchDirectoryContext } from "../../providers/user-directory-provider"; import { UserAvatar } from "../user-avatar"; import { useUserMetadata } from "../../hooks/use-user-metadata"; import { getUserDisplayName } from "../../helpers/user-metadata"; @@ -23,7 +23,7 @@ function UserOption({ pubkey }: { pubkey: string }) { export default function SearchModal({ isOpen, onClose }: Omit) { const searchRef = useRef(null); - const getDirectory = useUserDirectoryContext(); + const getDirectory = useUserSearchDirectoryContext(); const [inputValue, setInputValue] = useState(""); const search = useThrottle(inputValue); diff --git a/src/providers/index.tsx b/src/providers/index.tsx index cb63b040b..007a2b564 100644 --- a/src/providers/index.tsx +++ b/src/providers/index.tsx @@ -9,7 +9,7 @@ import { InvoiceModalProvider } from "./invoice-modal"; import NotificationTimelineProvider from "./notification-timeline"; import PostModalProvider from "./post-modal-provider"; import { DefaultEmojiProvider, UserEmojiProvider } from "./emoji-provider"; -import { AllUserDirectoryProvider } from "./user-directory-provider"; +import { AllUserSearchDirectoryProvider } from "./user-directory-provider"; import MuteModalProvider from "./mute-modal-provider"; import BreakpointProvider from "./breakpoint-provider"; @@ -39,9 +39,9 @@ export function PageProviders({ children }: { children: React.ReactNode }) { - + {children} - + diff --git a/src/providers/user-directory-provider.tsx b/src/providers/user-directory-provider.tsx index a26afd926..c46dc991a 100644 --- a/src/providers/user-directory-provider.tsx +++ b/src/providers/user-directory-provider.tsx @@ -1,17 +1,13 @@ import { PropsWithChildren, createContext, useCallback, useContext } from "react"; -import { useCurrentAccount } from "../hooks/use-current-account"; -import useUserContactList from "../hooks/use-user-contact-list"; -import { getPubkeysFromList } from "../helpers/nostr/lists"; -import userMetadataService from "../services/user-metadata"; import db from "../services/db"; export type UserDirectory = { pubkey: string; names: [] }[]; export type GetDirectoryFn = () => Promise | UserDirectory; -const UserDirectoryContext = createContext(async () => []); +const UserSearchDirectoryContext = createContext(async () => []); -export function useUserDirectoryContext() { - return useContext(UserDirectoryContext); +export function useUserSearchDirectoryContext() { + return useContext(UserSearchDirectoryContext); } // export function getNameDirectory(directory: UserDirectory) { @@ -46,19 +42,19 @@ export function useUserDirectoryContext() { // return {children}; // } -export function AllUserDirectoryProvider({ children }: PropsWithChildren) { +export function AllUserSearchDirectoryProvider({ children }: PropsWithChildren) { const getDirectory = useCallback(async () => { return await db.getAll("userSearch"); }, []); - return {children}; + return {children}; } -export default function UserDirectoryProvider({ +export default function UserSearchDirectoryProvider({ children, getDirectory, }: PropsWithChildren & { getDirectory: GetDirectoryFn }) { - const parent = useContext(UserDirectoryContext); + const parent = useContext(UserSearchDirectoryContext); const wrapper = useCallback<() => Promise>(async () => { const dir = parent ? await parent() : []; const newDir = await getDirectory(); @@ -68,5 +64,5 @@ export default function UserDirectoryProvider({ return dir; }, [parent, getDirectory]); - return {children}; + return {children}; } diff --git a/src/views/note/components/reply-form.tsx b/src/views/note/components/reply-form.tsx index 19392b261..7305695d1 100644 --- a/src/views/note/components/reply-form.tsx +++ b/src/views/note/components/reply-form.tsx @@ -22,7 +22,6 @@ import NostrPublishAction from "../../../classes/nostr-publish-action"; import { unique } from "../../../helpers/array"; import MagicTextArea, { RefType } from "../../../components/magic-textarea"; import { useContextEmojis } from "../../../providers/emoji-provider"; -import UserDirectoryProvider from "../../../providers/user-directory-provider"; import { TrustProvider } from "../../../providers/trust"; import { nostrBuildUploadImage } from "../../../helpers/nostr-build"; import { UploadImageIcon } from "../../../components/icons"; @@ -96,56 +95,54 @@ export default function ReplyForm({ item, onCancel, onSubmitted }: ReplyFormProp }); return ( - threadMembers}> - - setValue("content", e.target.value, { shouldDirty: true })} - instanceRef={(inst) => (textAreaRef.current = inst)} - onPaste={(e) => { - const imageFile = Array.from(e.clipboardData.files).find((f) => f.type.includes("image")); - if (imageFile) uploadImage(imageFile); + + setValue("content", e.target.value, { shouldDirty: true })} + instanceRef={(inst) => (textAreaRef.current = inst)} + onPaste={(e) => { + const imageFile = Array.from(e.clipboardData.files).find((f) => f.type.includes("image")); + if (imageFile) uploadImage(imageFile); + }} + /> + + { + const img = e.target.files?.[0]; + if (img) uploadImage(img); }} /> - - { - const img = e.target.files?.[0]; - if (img) uploadImage(img); - }} - /> - } - aria-label="Upload Image" - title="Upload Image" - onClick={() => imageUploadRef.current?.click()} - isLoading={uploading} - size="sm" - /> - - - - - - - {getValues().content.length > 0 && ( - - - - - - )} + } + aria-label="Upload Image" + title="Upload Image" + onClick={() => imageUploadRef.current?.click()} + isLoading={uploading} + size="sm" + /> + + + + + - + {getValues().content.length > 0 && ( + + + + + + )} + ); } diff --git a/src/views/streams/stream/index.tsx b/src/views/streams/stream/index.tsx index b23c766a4..90f7a844c 100644 --- a/src/views/streams/stream/index.tsx +++ b/src/views/streams/stream/index.tsx @@ -43,7 +43,7 @@ import { UserEmojiProvider } from "../../../providers/emoji-provider"; import StreamStatusBadge from "../components/status-badge"; import ChatMessageForm from "./stream-chat/stream-chat-form"; import useStreamChatTimeline from "./stream-chat/use-stream-chat-timeline"; -import UserDirectoryProvider from "../../../providers/user-directory-provider"; +import UserSearchDirectoryProvider from "../../../providers/user-directory-provider"; import StreamChatLog from "./stream-chat/chat-log"; import TopZappers from "../components/top-zappers"; import StreamHashtags from "../components/stream-hashtags"; @@ -206,20 +206,20 @@ function StreamPage({ stream }: { stream: ParsedStream }) { const isMobile = useBreakpointValue({ base: true, lg: false }); const Layout = isMobile ? MobileStreamPage : DesktopStreamPage; - const chatTimeline = useStreamChatTimeline(stream); - const chatLog = useSubject(chatTimeline.timeline); - const pubkeysInChat = useMemo(() => { - const set = new Set(); - for (const event of chatLog) { - set.add(event.pubkey); - } - return Array.from(set); - }, [chatLog]); + // const chatTimeline = useStreamChatTimeline(stream); + // const chatLog = useSubject(chatTimeline.timeline); + // const pubkeysInChat = useMemo(() => { + // const set = new Set(); + // for (const event of chatLog) { + // set.add(event.pubkey); + // } + // return Array.from(set); + // }, [chatLog]); return ( - pubkeysInChat}> - - + // pubkeysInChat}> + + // ); }