Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
owencraston committed Nov 15, 2024
1 parent 05a4231 commit dd8c2fa
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import React, { useCallback, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import { TextInput, View } from 'react-native';
import ApprovalModal from '../ApprovalModal';
import useApprovalRequest from '../../Views/confirmations/hooks/useApprovalRequest';
Expand Down Expand Up @@ -49,19 +49,12 @@ const SnapAccountCustomNameApproval = () => {
internalAccounts.some((account) => account.metadata.name === name);

useEffect(() => {
const suggestedName = approvalRequest?.requestData.snapSuggestedAccountName;
const initialName = suggestedName
? generateUniqueNameWithSuffix(suggestedName)
: Engine.context.AccountsController.getNextAvailableAccountName(
KeyringTypes.snap,
);
setAccountName(initialName);

function generateUniqueNameWithSuffix(baseName: string): string {
let suffix = 1;
let candidateName = baseName;
while (
internalAccounts.some(
// eslint-disable-next-line no-loop-func
(account) => account.metadata.name === candidateName,
)
) {
Expand All @@ -70,6 +63,14 @@ const SnapAccountCustomNameApproval = () => {
}
return candidateName;
}

const suggestedName = approvalRequest?.requestData.snapSuggestedAccountName;
const initialName = suggestedName
? generateUniqueNameWithSuffix(suggestedName)
: Engine.context.AccountsController.getNextAvailableAccountName(
KeyringTypes.snap,
);
setAccountName(initialName);
}, [approvalRequest, internalAccounts]);

const cancelButtonProps: ButtonProps = {
Expand Down

0 comments on commit dd8c2fa

Please sign in to comment.