Only trim name on create (#1756)

This commit is contained in:
Jaco Greeff 2019-10-24 11:10:19 +02:00 committed by GitHub
parent 4d2615850b
commit ac854e4d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -142,11 +142,7 @@ function Create ({ className, onClose, onStatusChange, seed: propsSeed, t, type:
setAddress(generateSeed(null, derivePath, newSeedType, pairType));
}
};
const _onChangeName = (_name: string): void => {
const name = _name.trim();
setName({ isNameValid: !!name, name });
};
const _onChangeName = (name: string): void => setName({ isNameValid: !!name.trim(), name });
const _toggleConfirmation = (): void => setIsConfirmationOpen(!isConfirmationOpen);
const _onCommit = (): void => {
@ -158,7 +154,7 @@ function Create ({ className, onClose, onStatusChange, seed: propsSeed, t, type:
const status = { action: 'create' } as ActionStatus;
try {
const { json, pair } = keyring.addUri(`${seed}${derivePath}`, password, { name, tags: [] }, pairType);
const { json, pair } = keyring.addUri(`${seed}${derivePath}`, password, { name: name.trim(), tags: [] }, pairType);
const blob = new Blob([JSON.stringify(json)], { type: 'application/json; charset=utf-8' });
const { address } = pair;

View File

@ -49,7 +49,7 @@ function Create ({ onClose, onStatusChange, t }: Props): React.ReactElement<Prop
setAddress({ address: address || input, isAddressExisting, isAddressValid });
};
const _onChangeName = (name: string): void => setName({ isNameValid: !!name, name });
const _onChangeName = (name: string): void => setName({ isNameValid: !!name.trim(), name });
const _onCommit = (): void => {
const status = { action: 'create' } as ActionStatus;
@ -58,7 +58,7 @@ function Create ({ onClose, onStatusChange, t }: Props): React.ReactElement<Prop
}
try {
keyring.saveAddress(address, { name, genesisHash: keyring.genesisHash, tags: [] });
keyring.saveAddress(address, { name: name.trim(), genesisHash: keyring.genesisHash, tags: [] });
status.account = address;
status.status = address ? 'success' : 'error';