Skip to content

Commit

Permalink
Merge pull request #2063 from novasamatech/fix/tbaut-proposer-address
Browse files Browse the repository at this point in the history
Fix: show proposer address if no identity is found
  • Loading branch information
Tbaut authored Aug 12, 2024
2 parents e70993a + 15b0f75 commit 4a07d48
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { pickNestedValue } from '@shared/lib/utils';
import { Markdown, Shimmering } from '@shared/ui';
import { TrackInfo, referendumService } from '@entities/governance';
import { detailsAggregate } from '../../aggregates/details';
import { networkSelectorModel } from '../../model/networkSelector';

import { ProposerName } from './ProposerName';

Expand All @@ -15,6 +16,8 @@ type Props = {

export const ProposalDescription = ({ chainId, referendum }: Props) => {
const isDescriptionLoading = useUnit(detailsAggregate.$isDescriptionLoading);
const addressPrefix = useUnit(networkSelectorModel.$governanceChain)?.addressPrefix;

const description = useStoreMap({
store: detailsAggregate.$descriptions,
keys: [chainId, referendum.referendumId],
Expand All @@ -24,7 +27,7 @@ export const ProposalDescription = ({ chainId, referendum }: Props) => {
return (
<div>
<div className="mb-4 flex items-center">
<ProposerName referendum={referendum} />
<ProposerName referendum={referendum} addressPrefix={addressPrefix} />
<div className="grow" />
{referendumService.isOngoing(referendum) && <TrackInfo trackId={referendum.track} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useStoreMap } from 'effector-react';

import { useI18n } from '@app/providers';
import { toAddress } from '@/shared/lib/utils';
import { type Referendum } from '@shared/core';
import { FootnoteText, Shimmering } from '@shared/ui';
import { referendumService } from '@entities/governance';
Expand All @@ -9,9 +10,10 @@ import { detailsAggregate } from '../../aggregates/details';

type Props = {
referendum: Referendum;
addressPrefix?: number;
};

export const ProposerName = ({ referendum }: Props) => {
export const ProposerName = ({ referendum, addressPrefix }: Props) => {
const { t } = useI18n();

const proposer = useStoreMap({
Expand All @@ -30,21 +32,26 @@ export const ProposerName = ({ referendum }: Props) => {
fn: (loading, [proposer]) => loading && !proposer,
});

if (!isProposerLoading && !proposer) {
return null;
}

const proposerName = proposer ? (
const proposerName = proposer?.parent ? (
<AccountAddress
addressFont="text-text-secondary"
size={16}
address={proposer.parent.address}
name={proposer.parent.name || proposer.email || proposer.twitter || proposer.parent.address}
/>
) : referendumService.isOngoing(referendum) && referendum.submissionDeposit?.who ? (
<AccountAddress
addressFont="text-text-secondary"
size={16}
address={referendum.submissionDeposit.who}
name={toAddress(referendum.submissionDeposit!.who, { chunk: 6, prefix: addressPrefix })}
/>
) : null;

const proposerLoader = isProposerLoading ? <Shimmering height={18} width={70} /> : null;

if (!proposerName && !proposerLoader) return null;

return (
<div className="flex items-center gap-2">
<FootnoteText className="text-text-secondary">{t('governance.referendum.proposer')}</FootnoteText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Timeline = ({ referendumId }: Props) => {

{!isLoading &&
timeline.map((status) => (
<div key={status.date.toLocaleString()} className="flex items-center justify-between">
<div key={`${status.status}-${status.date.toLocaleString()}`} className="flex items-center justify-between">
<FootnoteText>{formatDate(status.date, 'd MMM’yy, hh:mm')}</FootnoteText>
<OperationStatus pallet={getStatusPalette(status.status)}>
{/* eslint-disable-next-line i18next/no-literal-string */}
Expand Down

0 comments on commit 4a07d48

Please sign in to comment.