From 1a4c9dc49b445e38c62cd6a5a72578ee3bb866ed Mon Sep 17 00:00:00 2001 From: Shusui MOYATANI Date: Wed, 28 Jun 2023 01:24:41 +0900 Subject: [PATCH] feat: user list --- src/components/event/ProfileListItem.tsx | 64 +++++++++++++++++++ .../event/textNote/TextNoteDisplay.tsx | 60 +++++++++++++++-- src/components/modal/ProfileDisplay.tsx | 12 +++- src/components/modal/UserList.tsx | 41 ++++++++++++ 4 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 src/components/event/ProfileListItem.tsx create mode 100644 src/components/modal/UserList.tsx diff --git a/src/components/event/ProfileListItem.tsx b/src/components/event/ProfileListItem.tsx new file mode 100644 index 0000000..98f0c61 --- /dev/null +++ b/src/components/event/ProfileListItem.tsx @@ -0,0 +1,64 @@ +import { Component, Show, Switch, Match } from 'solid-js'; + +import useProfile from '@/nostr/useProfile'; +import npubEncodeFallback from '@/utils/npubEncodeFallback'; + +export type ProfileListItemProps = { + pubkey: string; + onShowProfile?: () => void; +}; + +const ProfileListItem: Component = (props) => { + const { profile, query } = useProfile(() => ({ + pubkey: props.pubkey, + })); + + return ( +
+ +
+
+ +
+
+
+ ); +}; + +export default ProfileListItem; diff --git a/src/components/event/textNote/TextNoteDisplay.tsx b/src/components/event/textNote/TextNoteDisplay.tsx index e55d9c0..b03db3b 100644 --- a/src/components/event/textNote/TextNoteDisplay.tsx +++ b/src/components/event/textNote/TextNoteDisplay.tsx @@ -1,4 +1,13 @@ -import { Show, For, createSignal, createMemo, type JSX, type Component } from 'solid-js'; +import { + Show, + For, + createSignal, + createMemo, + type JSX, + type Component, + Switch, + Match, +} from 'solid-js'; import { createMutation } from '@tanstack/solid-query'; import ArrowPathRoundedSquare from 'heroicons/24/outline/arrow-path-rounded-square.svg'; @@ -17,6 +26,7 @@ import ContentWarningDisplay from '@/components/event/textNote/ContentWarningDis import GeneralUserMentionDisplay from '@/components/event/textNote/GeneralUserMentionDisplay'; import TextNoteContentDisplay from '@/components/event/textNote/TextNoteContentDisplay'; import EventDebugModal from '@/components/modal/EventDebugModal'; +import UserList from '@/components/modal/UserList'; import NotePostForm from '@/components/NotePostForm'; import Post from '@/components/Post'; import { useTimelineContext } from '@/components/timeline/TimelineContext'; @@ -95,8 +105,10 @@ const TextNoteDisplay: Component = (props) => { const [reacted, setReacted] = createSignal(false); const [reposted, setReposted] = createSignal(false); const [showReplyForm, setShowReplyForm] = createSignal(false); - const [showEventDebug, setShowEventDebug] = createSignal(false); + const [modal, setModal] = createSignal<'EventDebugModal' | 'Reactions' | 'Reposts' | null>(null); + const closeReplyForm = () => setShowReplyForm(false); + const closeModal = () => setModal(null); const event = createMemo(() => textNote(props.event)); @@ -190,7 +202,19 @@ const TextNoteDisplay: Component = (props) => { { content: () => 'JSONを確認', onSelect: () => { - setShowEventDebug(true); + setModal('EventDebugModal'); + }, + }, + { + content: () => 'リポスト一覧', + onSelect: () => { + setModal('Reposts'); + }, + }, + { + content: () => 'リアクション一覧', + onSelect: () => { + setModal('Reactions'); }, }, { @@ -437,9 +461,33 @@ const TextNoteDisplay: Component = (props) => { timelineContext?.setTimeline({ type: 'Replies', event: props.event }); }} /> - - setShowEventDebug(false)} /> - + + + + + + ev.pubkey} + renderInfo={({ content }) => ( +
+ {content}} + > + + + + +
+ )} + onClose={closeModal} + /> +
+ + ev.pubkey} onClose={closeModal} /> + +
); }; diff --git a/src/components/modal/ProfileDisplay.tsx b/src/components/modal/ProfileDisplay.tsx index c057972..d93686c 100644 --- a/src/components/modal/ProfileDisplay.tsx +++ b/src/components/modal/ProfileDisplay.tsx @@ -10,6 +10,7 @@ import uniq from 'lodash/uniq'; import ContextMenu, { MenuItem } from '@/components/ContextMenu'; import BasicModal from '@/components/modal/BasicModal'; +import UserList from '@/components/modal/UserList'; import Timeline from '@/components/timeline/Timeline'; import SafeLink from '@/components/utils/SafeLink'; import useConfig from '@/core/useConfig'; @@ -51,6 +52,8 @@ const ProfileDisplay: Component = (props) => { const [updatingContacts, setUpdatingContacts] = createSignal(false); const [hoverFollowButton, setHoverFollowButton] = createSignal(false); const [showFollowers, setShowFollowers] = createSignal(false); + const [modal, setModal] = createSignal<'Following' | null>(false); + const closeModal = () => setModal(null); const { profile, query: profileQuery } = useProfile(() => ({ pubkey: props.pubkey, @@ -341,7 +344,7 @@ const ProfileDisplay: Component = (props) => {
-
+
+
フォロワー
@@ -389,6 +392,11 @@ const ProfileDisplay: Component = (props) => { + + + e} onClose={closeModal} /> + +
diff --git a/src/components/modal/UserList.tsx b/src/components/modal/UserList.tsx new file mode 100644 index 0000000..e0f68be --- /dev/null +++ b/src/components/modal/UserList.tsx @@ -0,0 +1,41 @@ +import { For, JSX, Show } from 'solid-js'; + +import ProfileListItem from '@/components/event/ProfileListItem'; +import BasicModal from '@/components/modal/BasicModal'; +import useModalState from '@/hooks/useModalState'; + +export type UserListProps = { + data: T[]; + pubkeyExtractor: (e: T) => string; + renderInfo?: (e: T) => JSX.Element; + onClose: () => void; +}; + +const UserList = (props: UserListProps): JSX.Element => { + const { showProfile } = useModalState(); + + return ( + +
+
{props.data.length} 件
+
+ + {(e) => { + const pubkey = () => props.pubkeyExtractor(e); + return ( +
+ + {(render) => render(e)} + + showProfile(pubkey())} /> +
+ ); + }} +
+
+
+
+ ); +}; + +export default UserList;