Skip to content

Commit

Permalink
fix: PinPad race condition 2
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 28, 2024
1 parent f32ddb3 commit ef7996d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
15 changes: 7 additions & 8 deletions src/screens/Settings/PIN/ChangePin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ const ChangePin = ({
const { brand, brand08 } = useColors();

const handleOnPress = (key: string): void => {
vibrate();
if (key === 'delete') {
if (pin.length !== 0) {
vibrate();
setPin((p) => p.slice(0, -1));
}
setPin((p) => {
return p.length === 0 ? '' : p.slice(0, -1);
});
} else {
if (pin.length !== 4) {
vibrate();
setPin((p) => p + key);
}
setPin((p) => {
return p.length === 4 ? p : p + key;
});
}
};

Expand Down
15 changes: 7 additions & 8 deletions src/screens/Settings/PIN/ChangePin2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ const ChangePin2 = ({
const { brand, brand08 } = useColors();

const handleOnPress = (key: string): void => {
vibrate();
if (key === 'delete') {
if (pin.length !== 0) {
vibrate();
setPin((p) => p.slice(0, -1));
}
setPin((p) => {
return p.length === 0 ? '' : p.slice(0, -1);
});
} else {
if (pin.length !== 4) {
vibrate();
setPin((p) => p + key);
}
setPin((p) => {
return p.length === 4 ? p : p + key;
});
}
};

Expand Down
15 changes: 7 additions & 8 deletions src/screens/Settings/PIN/ChoosePIN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ const ChoosePIN = ({
const { brand, brand08 } = useColors();

const handleOnPress = (key: string): void => {
vibrate();
if (key === 'delete') {
if (pin.length !== 0) {
vibrate();
setPin((p) => p.slice(0, -1));
}
setPin((p) => {
return p.length === 0 ? '' : p.slice(0, -1);
});
} else {
if (pin.length !== 4) {
vibrate();
setPin((p) => p + key);
}
setPin((p) => {
return p.length === 4 ? p : p + key;
});
}
};

Expand Down
15 changes: 7 additions & 8 deletions src/screens/Wallets/Send/SendPinPad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ const SendPinPad = ({ onSuccess }: { onSuccess: () => void }): ReactElement => {
const { brand, brand08 } = useColors();

const handleOnPress = (key: string): void => {
vibrate();
if (key === 'delete') {
if (pin.length !== 0) {
vibrate();
setPin((p) => p.slice(0, -1));
}
setPin((p) => {
return p.length === 0 ? '' : p.slice(0, -1);
});
} else {
if (pin.length !== 4) {
vibrate();
setPin((p) => p + key);
}
setPin((p) => {
return p.length === 4 ? p : p + key;
});
}
};

Expand Down

0 comments on commit ef7996d

Please sign in to comment.