fix: wrap rehash updateProfile in try/catch for best-effort (#54)
Both handlePinSuccess handlers (ProfileSwitcher and ProfileSelectionPage) now catch updateProfile errors so that a failed rehash persistence does not block switchProfile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2f610bf10a
commit
e5be6f5a56
2 changed files with 10 additions and 2 deletions
|
|
@ -39,7 +39,11 @@ export default function ProfileSwitcher() {
|
||||||
const handlePinSuccess = async (rehashed?: string | null) => {
|
const handlePinSuccess = async (rehashed?: string | null) => {
|
||||||
if (pinProfile) {
|
if (pinProfile) {
|
||||||
if (rehashed) {
|
if (rehashed) {
|
||||||
|
try {
|
||||||
await updateProfile(pinProfile.id, { pin_hash: rehashed });
|
await updateProfile(pinProfile.id, { pin_hash: rehashed });
|
||||||
|
} catch {
|
||||||
|
// Best-effort rehash: don't block profile switch if persistence fails
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switchProfile(pinProfile.id);
|
switchProfile(pinProfile.id);
|
||||||
setPinProfile(null);
|
setPinProfile(null);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,11 @@ export default function ProfileSelectionPage() {
|
||||||
const handlePinSuccess = async (rehashed?: string | null) => {
|
const handlePinSuccess = async (rehashed?: string | null) => {
|
||||||
if (pinProfileId) {
|
if (pinProfileId) {
|
||||||
if (rehashed) {
|
if (rehashed) {
|
||||||
|
try {
|
||||||
await updateProfile(pinProfileId, { pin_hash: rehashed });
|
await updateProfile(pinProfileId, { pin_hash: rehashed });
|
||||||
|
} catch {
|
||||||
|
// Best-effort rehash: don't block profile switch if persistence fails
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switchProfile(pinProfileId);
|
switchProfile(pinProfileId);
|
||||||
setPinProfileId(null);
|
setPinProfileId(null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue