forked from Kieran/snort
fix: rerender user timeline on pubkey change
This commit is contained in:
parent
ae4657feda
commit
8d40165a71
@ -15,7 +15,7 @@ export interface NoteReactionProps {
|
||||
root?: TaggedRawEvent
|
||||
}
|
||||
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(() => {
|
||||
if (ev) {
|
||||
@ -71,6 +71,7 @@ export default function NoteReaction(props: NoteReactionProps) {
|
||||
showHeader: ev?.Kind === EventKind.Repost,
|
||||
showFooter: ev?.Kind === EventKind.Repost,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="reaction">
|
||||
<div className="header flex">
|
||||
|
@ -14,15 +14,15 @@ export interface TimelineProps {
|
||||
* A list of notes by pubkeys
|
||||
*/
|
||||
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) {
|
||||
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(() => {
|
||||
return feed.main?.sort((a, b) => b.created_at - a.created_at);
|
||||
}, [feed]);
|
||||
return main?.sort((a, b) => b.created_at - a.created_at);
|
||||
}, [main]);
|
||||
|
||||
function eventElement(e: TaggedRawEvent) {
|
||||
switch (e.kind) {
|
||||
|
@ -83,7 +83,8 @@ export default function ProfilePage() {
|
||||
|
||||
function tabContent() {
|
||||
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: {
|
||||
if (isMe) {
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user