Skip to content

Commit

Permalink
Merge pull request #569 from logion-network/feature/fix-empty-llo-list
Browse files Browse the repository at this point in the history
Prevent freeze when legalOfficersWithNonVoidIdentityLoc is empty.
  • Loading branch information
benoitdevos authored May 13, 2024
2 parents 3d124ee + 0635d92 commit da1361e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/loc/IdentityLocRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function IdentityLocRequest(props: Props) {
const [ invalidCompanyName, setInvalidCompanyName ] = useState<string>();
const { accounts } = useLogionChain();
const navigate = useNavigate();
const selectablelegalOfficers = useMemo(() => {
const selectableLegalOfficers = useMemo(() => {
const legalOfficersWithNonVoidIdentityLoc = locsState?.legalOfficersWithNonVoidIdentityLoc.map(lo => lo.account.address);
return availableLegalOfficers?.filter(lo => legalOfficersWithNonVoidIdentityLoc?.includes(lo.account.address) === false);
}, [ locsState?.legalOfficersWithNonVoidIdentityLoc, availableLegalOfficers ]);
Expand Down Expand Up @@ -120,7 +120,7 @@ export default function IdentityLocRequest(props: Props) {
<SelectLegalOfficer
legalOfficer={ legalOfficer }
legalOfficerNumber={ 1 }
legalOfficers={ selectablelegalOfficers || [] }
legalOfficers={ selectableLegalOfficers || [] }
mode="select"
otherLegalOfficer={ null }
setLegalOfficer={ setLegalOfficer }
Expand Down
6 changes: 3 additions & 3 deletions src/wallet-user/protection/SelectLegalOfficer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export default function SelectLegalOfficer(props: Props) {
const colors = props.colors !== undefined ? props.colors : colorTheme.frame;
const feedback = props.feedback ? props.feedback : "Required and different from other legal officer";
const { label } = props;
const [ legalOfficersOptions, setLegalOfficersOptions ] = useState<OptionType<ValidAccountId>[]>([]);
const [ legalOfficersOptions, setLegalOfficersOptions ] = useState<OptionType<ValidAccountId>[]>();

const legalOfficersByAddress: Record<string, LegalOfficerClass> = {};
props.legalOfficers.forEach(legalOfficer => {
legalOfficersByAddress[legalOfficer.account.address] = legalOfficer;
});

useEffect(() => {
if(legalOfficersOptions.length === 0) {
if(legalOfficersOptions === undefined) {
buildOptions(props.legalOfficers)
.then(options => setLegalOfficersOptions(options));
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function SelectLegalOfficer(props: Props) {
control={
<Select
isInvalid={ props.legalOfficer === null || (props.otherLegalOfficer !== null && props.legalOfficer.account.equals(props.otherLegalOfficer.account)) }
options={ legalOfficersOptions }
options={ legalOfficersOptions || [] }
value={ props.legalOfficer !== null ? props.legalOfficer.account : null}
onChange={ value => props.setLegalOfficer!(legalOfficersByAddress[value!.address] || null) }
disabled={ props.mode === "view" }
Expand Down

0 comments on commit da1361e

Please sign in to comment.