Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Drop System theme option, keep Light/Dark with next-action tooltips

Anmol Kapile585ef269c5e
diff --git a/src/main/settings.ts b/src/main/settings.ts
index 61a5815..96e699f 100644
--- a/src/main/settings.ts
+++ b/src/main/settings.ts
@@ -1,6 +1,6 @@
import { readFile, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
-import { app } from 'electron'
+import { app, nativeTheme } from 'electron'
import type { ThemeSource } from '../shared/types'
function settingsPath(): string {
@@ -23,7 +23,12 @@ async function loadSettings(): Promise<AppSettings> {
export async function loadThemeSource(): Promise<ThemeSource> {
const settings = await loadSettings()
- return settings.themeSource ?? 'system'
+ if (settings.themeSource === 'light' || settings.themeSource === 'dark') {
+ return settings.themeSource
+ }
+ // First run, or a pre-existing settings file from when 'system' was an option — fall back to
+ // whatever the OS appearance is right now rather than defaulting to a fixed theme.
+ return nativeTheme.shouldUseDarkColors ? 'dark' : 'light'
}
export async function saveThemeSource(themeSource: ThemeSource): Promise<void> {
diff --git a/src/renderer/src/components/NetworkEditPopover.tsx b/src/renderer/src/components/NetworkEditPopover.tsx
index 49a6823..35e2e13 100644
--- a/src/renderer/src/components/NetworkEditPopover.tsx
+++ b/src/renderer/src/components/NetworkEditPopover.tsx
@@ -69,7 +69,7 @@ export function NetworkEditPopover({
type="button"
variant="ghost"
size="icon-xs"
- aria-label="Rename or recolor this network"
+ aria-label="Edit network"
className="shrink-0 text-muted-foreground"
>
<Pencil className="size-3" />
@@ -78,7 +78,7 @@ export function NetworkEditPopover({
/>
}
/>
- <TooltipContent>Rename or recolor this network</TooltipContent>
+ <TooltipContent>Edit network</TooltipContent>
</Tooltip>
<PopoverContent aria-label={`Edit ${visual.name}`} className="gap-3 p-3">
<div className="flex flex-col gap-[6px]">
diff --git a/src/renderer/src/components/ThemeToggle.tsx b/src/renderer/src/components/ThemeToggle.tsx
index a127aea..68a2a17 100644
--- a/src/renderer/src/components/ThemeToggle.tsx
+++ b/src/renderer/src/components/ThemeToggle.tsx
@@ -2,33 +2,10 @@ import type { ThemeSource } from '@shared/types'
import { useAppStore } from '../store/useAppStore'
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'
-const OPTIONS: { id: ThemeSource; label: string; icon: React.JSX.Element }[] = [
- {
- id: 'system',
- label: 'Appearance: System',
- icon: (
- <svg width="15" height="15" viewBox="0 0 16 16" fill="none">
- <rect
- x="1.5"
- y="2.5"
- width="13"
- height="9"
- rx="1.5"
- stroke="currentColor"
- strokeWidth="1.3"
- />
- <path
- d="M5.5 14.5h5M8 11.5v3"
- stroke="currentColor"
- strokeWidth="1.3"
- strokeLinecap="round"
- />
- </svg>
- )
- },
+const OPTIONS: { id: ThemeSource; nextLabel: string; icon: React.JSX.Element }[] = [
{
id: 'light',
- label: 'Appearance: Light',
+ nextLabel: 'Switch to dark theme',
icon: (
<svg width="15" height="15" viewBox="0 0 16 16" fill="none">
<circle cx="8" cy="8" r="3.2" stroke="currentColor" strokeWidth="1.3" />
@@ -43,7 +20,7 @@ const OPTIONS: { id: ThemeSource; label: string; icon: React.JSX.Element }[] = [
},
{
id: 'dark',
- label: 'Appearance: Dark',
+ nextLabel: 'Switch to light theme',
icon: (
<svg width="15" height="15" viewBox="0 0 16 16" fill="none">
<path
@@ -61,12 +38,10 @@ export function ThemeToggle(): React.JSX.Element {
const themeSource = useAppStore((store) => store.themeSource)
const setThemeSource = useAppStore((store) => store.setThemeSource)
- const index = OPTIONS.findIndex((option) => option.id === themeSource)
- const current = OPTIONS[index === -1 ? 0 : index]
+ const current = OPTIONS.find((option) => option.id === themeSource) ?? OPTIONS[0]
- const cycle = (): void => {
- const next = OPTIONS[(Math.max(index, 0) + 1) % OPTIONS.length]
- void setThemeSource(next.id)
+ const toggle = (): void => {
+ void setThemeSource(current.id === 'light' ? 'dark' : 'light')
}
return (
@@ -75,15 +50,15 @@ export function ThemeToggle(): React.JSX.Element {
render={
<button
type="button"
- aria-label={`${current.label} — click to change`}
- onClick={cycle}
+ aria-label={current.nextLabel}
+ onClick={toggle}
className="flex size-[26px] shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-[0.5px] border-border bg-secondary text-[var(--text-secondary)] [-webkit-app-region:no-drag]"
>
{current.icon}
</button>
}
/>
- <TooltipContent>{current.label} — click to change</TooltipContent>
+ <TooltipContent>{current.nextLabel}</TooltipContent>
</Tooltip>
)
}
diff --git a/src/renderer/src/store/useAppStore.ts b/src/renderer/src/store/useAppStore.ts
index c08713e..e5603ce 100644
--- a/src/renderer/src/store/useAppStore.ts
+++ b/src/renderer/src/store/useAppStore.ts
@@ -25,7 +25,7 @@ interface AppStore {
/** User customizations (name/color) per network interface id — persisted in the main process. */
networkPreferences: NetworkPreferences
- /** 'system' by default — persisted in the main process alongside nativeTheme.themeSource. */
+ /** Persisted in the main process alongside nativeTheme.themeSource. */
themeSource: ThemeSource
homeDir: string
@@ -67,7 +67,7 @@ export const useAppStore = create<AppStore>((set, get) => ({
interfacesError: null,
latencies: {},
networkPreferences: {},
- themeSource: 'system',
+ themeSource: 'light',
homeDir: '',
downloadsDir: '',
@@ -145,7 +145,7 @@ export const useAppStore = create<AppStore>((set, get) => ({
const themeSource = await window.plexo.getThemeSource()
set({ themeSource })
} catch {
- // Best-effort — a failed read just leaves the toggle showing the 'system' default.
+ // Best-effort — a failed read just leaves the toggle showing the 'light' default.
}
},
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 4f3a9e9..037252d 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1,7 +1,6 @@
export type NetworkInterfaceKind = 'wifi' | 'usb' | 'ethernet' | 'bridge' | 'other'
-/** 'system' follows the OS appearance; 'light'/'dark' pin it regardless of the OS setting. */
-export type ThemeSource = 'system' | 'light' | 'dark'
+export type ThemeSource = 'light' | 'dark'
export interface NetworkInterfaceInfo {
/** Stable identifier for this interface (currently the OS device name, e.g. "en0"). */