Merge pull request #77 from v0l/profile-loading
fix: rerender user timeline on pubkey change
This commit is contained in:
commit
a11372c9ca
@ -15,7 +15,7 @@ export interface NoteReactionProps {
|
|||||||
root?: TaggedRawEvent
|
root?: TaggedRawEvent
|
||||||
}
|
}
|
||||||
export default function NoteReaction(props: NoteReactionProps) {
|
export default function NoteReaction(props: NoteReactionProps) {
|
||||||
const ev = props["data-ev"] || new NEvent(props.data);
|
const ev = useMemo(() => props["data-ev"] || new NEvent(props.data), [props.data, props["data-ev"]])
|
||||||
|
|
||||||
const refEvent = useMemo(() => {
|
const refEvent = useMemo(() => {
|
||||||
if (ev) {
|
if (ev) {
|
||||||
@ -71,6 +71,7 @@ export default function NoteReaction(props: NoteReactionProps) {
|
|||||||
showHeader: ev?.Kind === EventKind.Repost,
|
showHeader: ev?.Kind === EventKind.Repost,
|
||||||
showFooter: ev?.Kind === EventKind.Repost,
|
showFooter: ev?.Kind === EventKind.Repost,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="reaction">
|
<div className="reaction">
|
||||||
<div className="header flex">
|
<div className="header flex">
|
||||||
|
@ -14,15 +14,15 @@ export interface TimelineProps {
|
|||||||
* A list of notes by pubkeys
|
* A list of notes by pubkeys
|
||||||
*/
|
*/
|
||||||
export default function Timeline({ global, pubkeys }: TimelineProps) {
|
export default function Timeline({ global, pubkeys }: TimelineProps) {
|
||||||
const feed = useTimelineFeed(pubkeys, global);
|
const { main, others } = useTimelineFeed(pubkeys, global);
|
||||||
|
|
||||||
function reaction(id: u256, kind = EventKind.Reaction) {
|
function reaction(id: u256, kind = EventKind.Reaction) {
|
||||||
return feed?.others?.filter(a => a.kind === kind && a.tags.some(b => b[0] === "e" && b[1] === id));
|
return others?.filter(a => a.kind === kind && a.tags.some(b => b[0] === "e" && b[1] === id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainFeed = useMemo(() => {
|
const mainFeed = useMemo(() => {
|
||||||
return feed.main?.sort((a, b) => b.created_at - a.created_at);
|
return main?.sort((a, b) => b.created_at - a.created_at);
|
||||||
}, [feed]);
|
}, [main]);
|
||||||
|
|
||||||
function eventElement(e: TaggedRawEvent) {
|
function eventElement(e: TaggedRawEvent) {
|
||||||
switch (e.kind) {
|
switch (e.kind) {
|
||||||
|
@ -83,7 +83,8 @@ export default function ProfilePage() {
|
|||||||
|
|
||||||
function tabContent() {
|
function tabContent() {
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case ProfileTab.Notes: return <Timeline pubkeys={[id]} global={false} />;
|
case ProfileTab.Notes:
|
||||||
|
return <Timeline key={id} pubkeys={[id]} global={false} />;
|
||||||
case ProfileTab.Follows: {
|
case ProfileTab.Follows: {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user