refactor: cleanup

This commit is contained in:
zhom
2026-08-27 09:16:25 +04:00
parent 63f673e7d4
commit 15b51f8d2d
31 changed files with 1471 additions and 339 deletions
+29 -3
View File
@@ -62,6 +62,7 @@ import {
} from "@/lib/themes";
import { showErrorToast, showSuccessToast } from "@/lib/toast-utils";
import { cn } from "@/lib/utils";
import type { SetDefaultBrowserOutcome } from "@/types";
import { RippleButton } from "./ui/ripple";
interface AppSettings {
@@ -401,14 +402,39 @@ export function SettingsDialog({
const handleSetDefaultBrowser = useCallback(async () => {
setIsSettingDefault(true);
try {
await invoke("set_as_default_browser");
// Windows keeps the final choice for its own settings page, so a call
// that succeeded does not always mean Donut is the default yet. Say which
// of the two happened. Saying nothing at all is what left the user
// watching the badge stay "Inactive" with no explanation.
const outcome = await invoke<SetDefaultBrowserOutcome>(
"set_as_default_browser",
);
await checkDefaultBrowserStatus();
if (outcome.status === "awaitingSystemSettings") {
showSuccessToast(t("settings.defaultBrowser.finishInSystemSettings"), {
description: t(
"settings.defaultBrowser.finishInSystemSettingsDescription",
),
duration: 8000,
});
} else {
showSuccessToast(t("settings.defaultBrowser.setSuccess"));
}
} catch (error) {
console.error("Failed to set as default browser:", error);
showErrorToast(t("settings.defaultBrowser.setFailed"), {
description:
error instanceof Error
? error.message
: typeof error === "string"
? error
: t("common.errors.unknown"),
duration: 8000,
});
} finally {
setIsSettingDefault(false);
}
}, [checkDefaultBrowserStatus]);
}, [checkDefaultBrowserStatus, t]);
const handleClearTraffic = useCallback(async () => {
setIsClearingTraffic(true);
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Default Browser",
"setAsDefault": "Set as Default Browser",
"alreadyDefault": "Already Default Browser",
"description": "When set as default, Donut Browser will handle web links and allow you to choose which profile to use."
"description": "When set as default, Donut Browser will handle web links and allow you to choose which profile to use.",
"setSuccess": "Donut Browser is now your default browser",
"setFailed": "Could not set the default browser",
"finishInSystemSettings": "Finish in Windows Settings",
"finishInSystemSettingsDescription": "Donut Browser is registered. Windows Settings is open: choose Donut Browser under Web browser to finish."
},
"permissions": {
"title": "System Permissions",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Navegador Predeterminado",
"setAsDefault": "Establecer como Navegador Predeterminado",
"alreadyDefault": "Ya es el Navegador Predeterminado",
"description": "Cuando se establece como predeterminado, Donut Browser manejará los enlaces web y te permitirá elegir qué perfil usar."
"description": "Cuando se establece como predeterminado, Donut Browser manejará los enlaces web y te permitirá elegir qué perfil usar.",
"setSuccess": "Donut Browser ya es tu navegador predeterminado",
"setFailed": "No se pudo establecer el navegador predeterminado",
"finishInSystemSettings": "Termina en la Configuración de Windows",
"finishInSystemSettingsDescription": "Donut Browser está registrado. Se abrió la Configuración de Windows: elige Donut Browser en Navegador web para terminar."
},
"permissions": {
"title": "Permisos del Sistema",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Navigateur par défaut",
"setAsDefault": "Définir comme navigateur par défaut",
"alreadyDefault": "Déjà le navigateur par défaut",
"description": "Lorsqu'il est défini par défaut, Donut Browser gérera les liens web et vous permettra de choisir quel profil utiliser."
"description": "Lorsqu'il est défini par défaut, Donut Browser gérera les liens web et vous permettra de choisir quel profil utiliser.",
"setSuccess": "Donut Browser est maintenant votre navigateur par défaut",
"setFailed": "Impossible de définir le navigateur par défaut",
"finishInSystemSettings": "Terminez dans les Paramètres Windows",
"finishInSystemSettingsDescription": "Donut Browser est enregistré. Les Paramètres Windows sont ouverts : choisissez Donut Browser sous Navigateur web pour terminer."
},
"permissions": {
"title": "Permissions système",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "デフォルトブラウザ",
"setAsDefault": "デフォルトブラウザに設定",
"alreadyDefault": "既にデフォルトブラウザです",
"description": "デフォルトに設定すると、Donut Browser がウェブリンクを処理し、使用するプロファイルを選択できます。"
"description": "デフォルトに設定すると、Donut Browser がウェブリンクを処理し、使用するプロファイルを選択できます。",
"setSuccess": "Donut Browser が既定のブラウザーになりました",
"setFailed": "既定のブラウザーを設定できませんでした",
"finishInSystemSettings": "Windows の設定で完了してください",
"finishInSystemSettingsDescription": "Donut Browser を登録しました。Windows の設定が開いています。「Web ブラウザー」で Donut Browser を選ぶと完了します。"
},
"permissions": {
"title": "システム権限",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "기본 브라우저",
"setAsDefault": "기본 브라우저로 설정",
"alreadyDefault": "이미 기본 브라우저입니다",
"description": "기본 브라우저로 설정하면 Donut Browser가 웹 링크를 처리하고 사용할 프로필을 선택할 수 있습니다."
"description": "기본 브라우저로 설정하면 Donut Browser가 웹 링크를 처리하고 사용할 프로필을 선택할 수 있습니다.",
"setSuccess": "이제 Donut Browser가 기본 브라우저입니다",
"setFailed": "기본 브라우저를 설정하지 못했습니다",
"finishInSystemSettings": "Windows 설정에서 완료하세요",
"finishInSystemSettingsDescription": "Donut Browser가 등록되었습니다. Windows 설정이 열려 있습니다. '웹 브라우저'에서 Donut Browser를 선택하면 완료됩니다."
},
"permissions": {
"title": "시스템 권한",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Navegador Padrão",
"setAsDefault": "Definir como Navegador Padrão",
"alreadyDefault": "Já é o Navegador Padrão",
"description": "Quando definido como padrão, o Donut Browser lidará com links da web e permitirá que você escolha qual perfil usar."
"description": "Quando definido como padrão, o Donut Browser lidará com links da web e permitirá que você escolha qual perfil usar.",
"setSuccess": "O Donut Browser agora é o seu navegador padrão",
"setFailed": "Não foi possível definir o navegador padrão",
"finishInSystemSettings": "Conclua nas Configurações do Windows",
"finishInSystemSettingsDescription": "O Donut Browser está registrado. As Configurações do Windows foram abertas: escolha o Donut Browser em Navegador da web para concluir."
},
"permissions": {
"title": "Permissões do Sistema",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Браузер по умолчанию",
"setAsDefault": "Установить браузером по умолчанию",
"alreadyDefault": "Уже браузер по умолчанию",
"description": "При установке по умолчанию Donut Browser будет обрабатывать веб-ссылки и позволит выбрать профиль для использования."
"description": "При установке по умолчанию Donut Browser будет обрабатывать веб-ссылки и позволит выбрать профиль для использования.",
"setSuccess": "Donut Browser теперь браузер по умолчанию",
"setFailed": "Не удалось назначить браузер по умолчанию",
"finishInSystemSettings": "Завершите в параметрах Windows",
"finishInSystemSettingsDescription": "Donut Browser зарегистрирован. Параметры Windows открыты: выберите Donut Browser в разделе «Веб-браузер», чтобы завершить."
},
"permissions": {
"title": "Системные разрешения",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Varsayılan Tarayıcı",
"setAsDefault": "Varsayılan Tarayıcı Olarak Ayarla",
"alreadyDefault": "Zaten Varsayılan Tarayıcı",
"description": "Varsayılan olarak ayarlandığında, Donut Browser web bağlantılarını yönetir ve hangi profilin kullanılacağını seçmenize olanak tanır."
"description": "Varsayılan olarak ayarlandığında, Donut Browser web bağlantılarını yönetir ve hangi profilin kullanılacağını seçmenize olanak tanır.",
"setSuccess": "Donut Browser artık varsayılan tarayıcınız",
"setFailed": "Varsayılan tarayıcı ayarlanamadı",
"finishInSystemSettings": "Windows Ayarları'nda tamamlayın",
"finishInSystemSettingsDescription": "Donut Browser kaydedildi. Windows Ayarları açıldı: tamamlamak için Web tarayıcısı bölümünden Donut Browser'ı seçin."
},
"permissions": {
"title": "Sistem İzinleri",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "Trình duyệt mặc định",
"setAsDefault": "Đặt làm trình duyệt mặc định",
"alreadyDefault": "Đã là trình duyệt mặc định",
"description": "Khi được đặt làm mặc định, Donut Browser sẽ xử lý các liên kết web và cho phép bạn chọn hồ sơ để sử dụng."
"description": "Khi được đặt làm mặc định, Donut Browser sẽ xử lý các liên kết web và cho phép bạn chọn hồ sơ để sử dụng.",
"setSuccess": "Donut Browser hiện là trình duyệt mặc định của bạn",
"setFailed": "Không thể đặt trình duyệt mặc định",
"finishInSystemSettings": "Hoàn tất trong Cài đặt Windows",
"finishInSystemSettingsDescription": "Donut Browser đã được đăng ký. Cài đặt Windows đang mở: chọn Donut Browser trong mục Trình duyệt web để hoàn tất."
},
"permissions": {
"title": "Quyền hệ thống",
+5 -1
View File
@@ -134,7 +134,11 @@
"title": "默认浏览器",
"setAsDefault": "设为默认浏览器",
"alreadyDefault": "已是默认浏览器",
"description": "设为默认后,Donut Browser 将处理网页链接并允许您选择使用哪个配置文件。"
"description": "设为默认后,Donut Browser 将处理网页链接并允许您选择使用哪个配置文件。",
"setSuccess": "Donut Browser 现在是您的默认浏览器",
"setFailed": "无法设置默认浏览器",
"finishInSystemSettings": "请在 Windows 设置中完成",
"finishInSystemSettingsDescription": "Donut Browser 已注册。Windows 设置已打开:在“Web 浏览器”中选择 Donut Browser 即可完成。"
},
"permissions": {
"title": "系统权限",
+13
View File
@@ -818,3 +818,16 @@ export interface PreLaunchChecks {
exit_measurement_unreliable: boolean;
consent_token: string | null;
}
/**
* What happened when the user asked Donut to become the default browser.
*
* macOS and Linux let a program make the change itself, so the answer there is
* always "set". Windows reserves the final choice for its own settings page:
* the app registers itself, Windows Settings opens, and the user finishes the
* job. Treating that case as plain success is how the button used to report a
* change that had not happened.
*/
export type SetDefaultBrowserOutcome =
| { status: "set" }
| { status: "awaitingSystemSettings" };