Skip to content

Commit

Permalink
fix empty owners list asset action
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Aug 12, 2024
1 parent f15a017 commit debf85b
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/views/Asset/AssetAction/AssetAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ export default function AssetAction(props: IProps) {
if (props.asset && props.asset.orders) {
const sortedOrders = sortOrders(props.asset.orders, 'low-to-high');

setCurrentListings(
sortedOrders.map((order: any) => ({
profile: order.profile,
...order,
}))
);

let profiles: RegistryProfileType[] | null = null;
try {
profiles = await getRegistryProfiles({ profileIds: sortedOrders.map((order: any) => order.creator) });
Expand Down Expand Up @@ -398,6 +405,13 @@ export default function AssetAction(props: IProps) {
}`
: null;

function showCurrentlyOwnedBy() {
if (!props.asset || !props.asset.state || !props.asset.state.balances) return false;
if (Object.keys(props.asset.state.balances).length <= 0) return false;
if (Object.keys(props.asset.state.balances).length === 1 && props.asset.state.balances[AO.ucm]) return false;
return true;
}

return props.asset ? (
<>
<S.Wrapper>
Expand All @@ -407,21 +421,18 @@ export default function AssetAction(props: IProps) {
<S.Header>
<h4>{props.asset.data.title}</h4>
<S.OwnerLinesWrapper>
{props.asset &&
props.asset.state &&
props.asset.state.balances &&
Object.keys(props.asset.state.balances).length > 0 && (
<S.OwnerLine>
<span>{language.currentlyOwnedBy}</span>
<button
onClick={() => {
setShowCurrentOwnersModal(true);
}}
>
{ownerCountDisplay}
</button>
</S.OwnerLine>
)}
{showCurrentlyOwnedBy() && (
<S.OwnerLine>
<span>{language.currentlyOwnedBy}</span>
<button
onClick={() => {
setShowCurrentOwnersModal(true);
}}
>
{ownerCountDisplay}
</button>
</S.OwnerLine>
)}
{currentListings && currentListings.length > 0 && (
<S.OwnerLine>
<span>{language.currentlyBeingSoldBy}</span>
Expand Down

0 comments on commit debf85b

Please sign in to comment.