display full node if different

This commit is contained in:
Roland Osborne 2022-06-27 13:29:37 -07:00
parent 42bd9607e8
commit f6087e7f1e
3 changed files with 20 additions and 5 deletions

View File

@ -9,9 +9,6 @@ export function Cards({ showRegistry }) {
const { state, actions } = useCards(); const { state, actions } = useCards();
useEffect(() => {
}, [showRegistry]);
const onSelect = (item) => { const onSelect = (item) => {
actions.select(item); actions.select(item);
} }
@ -30,6 +27,17 @@ export function Cards({ showRegistry }) {
return null return null
} }
const cardHandle = (item) => {
const profile = item.data?.cardProfile
if (profile) {
if (profile.node == state.node) {
return profile.handle;
}
return profile.handle + '@' + profile.node;
}
return null;
}
return ( return (
<CardsWrapper> <CardsWrapper>
<Drawer <Drawer
@ -56,7 +64,7 @@ export function Cards({ showRegistry }) {
imageSet={cardProfile(item).imageSet} /> imageSet={cardProfile(item).imageSet} />
</div> </div>
<div class="username"> <div class="username">
<span class="handle">{ cardProfile(item).handle }</span> <span class="handle">{ cardHandle(item) }</span>
<span class="name">{ cardProfile(item).name }</span> <span class="name">{ cardProfile(item).name }</span>
</div> </div>
</div> </div>

View File

@ -46,7 +46,7 @@ export const CardItem = styled(List.Item)`
} }
.handle { .handle {
font-size: 0.9em; font-size: 0.7em;
font-weight: bold; font-weight: bold;
} }
`; `;

View File

@ -1,15 +1,18 @@
import { useContext, useState, useEffect } from 'react'; import { useContext, useState, useEffect } from 'react';
import { CardContext } from 'context/CardContext'; import { CardContext } from 'context/CardContext';
import { ProfileContext } from 'context/ProfileContext';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
export function useCards() { export function useCards() {
const [state, setState] = useState({ const [state, setState] = useState({
cards: [], cards: [],
node: null,
}); });
const navigate = useNavigate(); const navigate = useNavigate();
const card = useContext(CardContext); const card = useContext(CardContext);
const profile = useContext(ProfileContext);
const actions = { const actions = {
getImageUrl: card.actions.getImageUrl, getImageUrl: card.actions.getImageUrl,
@ -45,5 +48,9 @@ export function useCards() {
})}); })});
}, [card]) }, [card])
useEffect(() => {
updateState({ node: profile.state?.profile?.node });
}, [profile])
return { state, actions }; return { state, actions };
} }