refactor: better error handling and prevention of creating ephemeral password protected profiles

This commit is contained in:
zhom
2026-05-12 13:03:34 +04:00
parent 06b5a41b37
commit 2633e2ba09
20 changed files with 170 additions and 9 deletions
+3
View File
@@ -11,6 +11,7 @@ export type BackendErrorCode =
| "PROFILE_NOT_PROTECTED"
| "PROFILE_ALREADY_PROTECTED"
| "PROFILE_RUNNING"
| "PROFILE_EPHEMERAL"
| "PROFILE_MISSING_SALT"
| "PROFILE_LOCKED"
| "INVALID_PROFILE_ID"
@@ -74,6 +75,8 @@ export function translateBackendError(t: TFunction, err: unknown): string {
return t("backendErrors.profileAlreadyProtected");
case "PROFILE_RUNNING":
return t("backendErrors.profileRunning");
case "PROFILE_EPHEMERAL":
return t("backendErrors.profileEphemeral");
case "PROFILE_MISSING_SALT":
return t("backendErrors.profileMissingSalt");
case "PROFILE_LOCKED":
+7
View File
@@ -9,6 +9,7 @@ import {
FaFire,
FaFirefox,
} from "react-icons/fa";
import { LuLock } from "react-icons/lu";
/**
* Map internal browser names to display names
@@ -42,7 +43,13 @@ export function getBrowserIcon(browserType: string) {
export function getProfileIcon(profile: {
browser: string;
ephemeral?: boolean;
password_protected?: boolean;
}) {
// `password_protected` and `ephemeral` are mutually exclusive (the backend
// rejects setting a password on an ephemeral profile), so the order here
// doesn't matter — checking lock first only matters if the invariant is
// ever violated, in which case showing the lock is the safer default.
if (profile.password_protected) return LuLock;
if (profile.ephemeral) return FaFire;
return getBrowserIcon(profile.browser);
}