mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-06-10 16:57:52 +02:00
refactor: better tombstone handling
This commit is contained in:
@@ -1648,14 +1648,18 @@ export function ProfilesDataTable({
|
||||
|
||||
// Cross-OS profiles: show OS icon when checkboxes aren't visible, show checkbox when they are
|
||||
if (isCrossOs && !meta.showCheckboxes && !isSelected) {
|
||||
const osName = profile.host_os
|
||||
? getOSDisplayName(profile.host_os)
|
||||
const resolvedOs =
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os;
|
||||
const osName = resolvedOs
|
||||
? getOSDisplayName(resolvedOs)
|
||||
: "another OS";
|
||||
const crossOsTooltip = t("crossOs.viewOnly", { os: osName });
|
||||
const OsIcon =
|
||||
profile.host_os === "macos"
|
||||
resolvedOs === "macos"
|
||||
? FaApple
|
||||
: profile.host_os === "windows"
|
||||
: resolvedOs === "windows"
|
||||
? FaWindows
|
||||
: FaLinux;
|
||||
return (
|
||||
@@ -1684,8 +1688,12 @@ export function ProfilesDataTable({
|
||||
|
||||
// Cross-OS profiles with checkboxes visible: show checkbox (selectable for bulk delete)
|
||||
if (isCrossOs && (meta.showCheckboxes || isSelected)) {
|
||||
const osName = profile.host_os
|
||||
? getOSDisplayName(profile.host_os)
|
||||
const resolvedOs =
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os;
|
||||
const osName = resolvedOs
|
||||
? getOSDisplayName(resolvedOs)
|
||||
: "another OS";
|
||||
const crossOsTooltip = t("crossOs.viewOnly", { os: osName });
|
||||
return (
|
||||
@@ -2017,7 +2025,7 @@ export function ProfilesDataTable({
|
||||
);
|
||||
|
||||
const isCrossOs = isCrossOsProfile(profile);
|
||||
const isCrossOsBlocked = isCrossOs && !meta.crossOsUnlocked;
|
||||
const isCrossOsBlocked = isCrossOs;
|
||||
const isRunning =
|
||||
meta.isClient && meta.runningProfiles.has(profile.id);
|
||||
const isLaunching = meta.launchingProfiles.has(profile.id);
|
||||
@@ -2078,7 +2086,7 @@ export function ProfilesDataTable({
|
||||
const meta = table.options.meta as TableMeta;
|
||||
const profile = row.original;
|
||||
const isCrossOs = isCrossOsProfile(profile);
|
||||
const isCrossOsBlocked = isCrossOs && !meta.crossOsUnlocked;
|
||||
const isCrossOsBlocked = isCrossOs;
|
||||
const isRunning =
|
||||
meta.isClient && meta.runningProfiles.has(profile.id);
|
||||
const isLaunching = meta.launchingProfiles.has(profile.id);
|
||||
@@ -2107,7 +2115,7 @@ export function ProfilesDataTable({
|
||||
const meta = table.options.meta as TableMeta;
|
||||
const profile = row.original;
|
||||
const isCrossOs = isCrossOsProfile(profile);
|
||||
const isCrossOsBlocked = isCrossOs && !meta.crossOsUnlocked;
|
||||
const isCrossOsBlocked = isCrossOs;
|
||||
const isRunning =
|
||||
meta.isClient && meta.runningProfiles.has(profile.id);
|
||||
const isLaunching = meta.launchingProfiles.has(profile.id);
|
||||
@@ -2134,7 +2142,7 @@ export function ProfilesDataTable({
|
||||
const meta = table.options.meta as TableMeta;
|
||||
const profile = row.original;
|
||||
const isCrossOs = isCrossOsProfile(profile);
|
||||
const isCrossOsBlocked = isCrossOs && !meta.crossOsUnlocked;
|
||||
const isCrossOsBlocked = isCrossOs;
|
||||
const isRunning =
|
||||
meta.isClient && meta.runningProfiles.has(profile.id);
|
||||
const isLaunching = meta.launchingProfiles.has(profile.id);
|
||||
@@ -2534,7 +2542,12 @@ export function ProfilesDataTable({
|
||||
const rowIsCrossOs = isCrossOsProfile(row.original);
|
||||
const crossOsTitle = rowIsCrossOs
|
||||
? t("crossOs.viewOnly", {
|
||||
os: getOSDisplayName(row.original.host_os ?? ""),
|
||||
os: getOSDisplayName(
|
||||
row.original.host_os ||
|
||||
row.original.camoufox_config?.os ||
|
||||
row.original.wayfern_config?.os ||
|
||||
"",
|
||||
),
|
||||
})
|
||||
: undefined;
|
||||
return (
|
||||
|
||||
@@ -211,7 +211,7 @@ export function ProfileInfoDialog({
|
||||
profile.release_type.slice(1);
|
||||
const hasTags = profile.tags && profile.tags.length > 0;
|
||||
const hasNote = !!profile.note;
|
||||
const showCrossOs = !!(profile.host_os && isCrossOsProfile(profile));
|
||||
const showCrossOs = isCrossOsProfile(profile);
|
||||
|
||||
type ActionItem = {
|
||||
icon: React.ReactNode;
|
||||
@@ -364,10 +364,22 @@ export function ProfileInfoDialog({
|
||||
{t("profiles.ephemeralBadge")}
|
||||
</Badge>
|
||||
)}
|
||||
{showCrossOs && profile.host_os && (
|
||||
{showCrossOs && (
|
||||
<Badge variant="outline" className="text-xs gap-1">
|
||||
<OSIcon os={profile.host_os} />
|
||||
{getOSDisplayName(profile.host_os)}
|
||||
<OSIcon
|
||||
os={
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os ||
|
||||
""
|
||||
}
|
||||
/>
|
||||
{getOSDisplayName(
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os ||
|
||||
"",
|
||||
)}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useBrowserState(
|
||||
_isUpdating: (browser: string) => boolean,
|
||||
launchingProfiles: Set<string>,
|
||||
stoppingProfiles: Set<string>,
|
||||
crossOsUnlocked = false,
|
||||
_crossOsUnlocked = false,
|
||||
) {
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
|
||||
@@ -53,7 +53,7 @@ export function useBrowserState(
|
||||
(profile: BrowserProfile): boolean => {
|
||||
if (!isClient) return false;
|
||||
|
||||
if (isCrossOsProfile(profile) && !crossOsUnlocked) return false;
|
||||
if (isCrossOsProfile(profile)) return false;
|
||||
|
||||
const isRunning = runningProfiles.has(profile.id);
|
||||
const isLaunching = launchingProfiles.has(profile.id);
|
||||
@@ -81,7 +81,6 @@ export function useBrowserState(
|
||||
isAnyInstanceRunning,
|
||||
launchingProfiles,
|
||||
stoppingProfiles,
|
||||
crossOsUnlocked,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -158,11 +157,16 @@ export function useBrowserState(
|
||||
(profile: BrowserProfile): string => {
|
||||
if (!isClient) return "Loading...";
|
||||
|
||||
if (isCrossOsProfile(profile) && profile.host_os) {
|
||||
if (!crossOsUnlocked) {
|
||||
const osName = getOSDisplayName(profile.host_os);
|
||||
return `This profile was created on ${osName}. A paid subscription is required to launch cross-OS profiles.`;
|
||||
if (isCrossOsProfile(profile)) {
|
||||
const profileOs =
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os;
|
||||
if (profileOs) {
|
||||
const osName = getOSDisplayName(profileOs);
|
||||
return `This profile was created on ${osName} and cannot be launched on a different operating system.`;
|
||||
}
|
||||
return "This profile was created on a different operating system and cannot be launched here.";
|
||||
}
|
||||
|
||||
const isRunning = runningProfiles.has(profile.id);
|
||||
@@ -197,7 +201,6 @@ export function useBrowserState(
|
||||
canLaunchProfile,
|
||||
launchingProfiles,
|
||||
stoppingProfiles,
|
||||
crossOsUnlocked,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -57,9 +57,17 @@ export const getCurrentOS = () => {
|
||||
return "unknown";
|
||||
};
|
||||
|
||||
export function isCrossOsProfile(profile: { host_os?: string }): boolean {
|
||||
if (!profile.host_os) return false;
|
||||
return profile.host_os !== getCurrentOS();
|
||||
export function isCrossOsProfile(profile: {
|
||||
host_os?: string;
|
||||
camoufox_config?: { os?: string };
|
||||
wayfern_config?: { os?: string };
|
||||
}): boolean {
|
||||
const profileOs =
|
||||
profile.host_os ||
|
||||
profile.camoufox_config?.os ||
|
||||
profile.wayfern_config?.os;
|
||||
if (!profileOs) return false;
|
||||
return profileOs !== getCurrentOS();
|
||||
}
|
||||
|
||||
export function getOSDisplayName(os: string): string {
|
||||
|
||||
Reference in New Issue
Block a user