polish(app): align desktop updates copy and labeling
This commit is contained in:
@@ -24,7 +24,7 @@ export function DesktopPermissionsSection() {
|
|||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<View style={styles.permissionSectionHeader}>
|
<View style={styles.permissionSectionHeader}>
|
||||||
<Text style={styles.sectionTitle}>Desktop permissions</Text>
|
<Text style={styles.sectionTitle}>Desktop Permissions</Text>
|
||||||
<Pressable
|
<Pressable
|
||||||
style={({ pressed }) => [
|
style={({ pressed }) => [
|
||||||
styles.permissionRefreshButton,
|
styles.permissionRefreshButton,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
buildDaemonUpdateDiagnostics,
|
buildDaemonUpdateDiagnostics,
|
||||||
findLikelyLocalDaemonHost,
|
findLikelyLocalDaemonHost,
|
||||||
formatVersionWithPrefix,
|
formatVersionWithPrefix,
|
||||||
|
isLikelyLocalHost,
|
||||||
isVersionMismatch,
|
isVersionMismatch,
|
||||||
runLocalDaemonUpdate,
|
runLocalDaemonUpdate,
|
||||||
shouldShowDesktopUpdateSection,
|
shouldShowDesktopUpdateSection,
|
||||||
@@ -32,6 +33,7 @@ export function DesktopUpdatesSection({ appVersion }: DesktopUpdatesSectionProps
|
|||||||
|
|
||||||
const appVersionText = formatVersionWithPrefix(appVersion);
|
const appVersionText = formatVersionWithPrefix(appVersion);
|
||||||
const localDaemonHost = useMemo(() => findLikelyLocalDaemonHost(daemons), [daemons]);
|
const localDaemonHost = useMemo(() => findLikelyLocalDaemonHost(daemons), [daemons]);
|
||||||
|
const hasLikelyLocalDaemon = isLikelyLocalHost(localDaemonHost);
|
||||||
const localDaemonServerId = localDaemonHost?.serverId ?? null;
|
const localDaemonServerId = localDaemonHost?.serverId ?? null;
|
||||||
const localDaemonVersion = useSessionStore(
|
const localDaemonVersion = useSessionStore(
|
||||||
useCallback(
|
useCallback(
|
||||||
@@ -44,6 +46,14 @@ export function DesktopUpdatesSection({ appVersion }: DesktopUpdatesSectionProps
|
|||||||
);
|
);
|
||||||
const localDaemonVersionText = formatVersionWithPrefix(localDaemonVersion);
|
const localDaemonVersionText = formatVersionWithPrefix(localDaemonVersion);
|
||||||
const daemonVersionMismatch = isVersionMismatch(appVersion, localDaemonVersion);
|
const daemonVersionMismatch = isVersionMismatch(appVersion, localDaemonVersion);
|
||||||
|
const daemonVersionTitle = hasLikelyLocalDaemon
|
||||||
|
? "Local daemon version"
|
||||||
|
: "Connected daemon version";
|
||||||
|
const daemonHostHint = localDaemonHost
|
||||||
|
? hasLikelyLocalDaemon
|
||||||
|
? `Connected host: ${localDaemonHost.label}`
|
||||||
|
: `No local daemon detected. Showing connected host: ${localDaemonHost.label}.`
|
||||||
|
: "No local daemon detected yet.";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isDesktop: isDesktopUpdaterAvailable,
|
isDesktop: isDesktopUpdaterAvailable,
|
||||||
@@ -195,12 +205,8 @@ export function DesktopUpdatesSection({ appVersion }: DesktopUpdatesSectionProps
|
|||||||
</View>
|
</View>
|
||||||
<View style={[styles.audioRow, styles.audioRowBorder]}>
|
<View style={[styles.audioRow, styles.audioRowBorder]}>
|
||||||
<View style={styles.audioRowContent}>
|
<View style={styles.audioRowContent}>
|
||||||
<Text style={styles.audioRowTitle}>Local daemon version</Text>
|
<Text style={styles.audioRowTitle}>{daemonVersionTitle}</Text>
|
||||||
<Text style={styles.updateHintText}>
|
<Text style={styles.updateHintText}>{daemonHostHint}</Text>
|
||||||
{localDaemonHost
|
|
||||||
? `Connected host: ${localDaemonHost.label}`
|
|
||||||
: "No local daemon detected yet."}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.aboutValue}>{localDaemonVersionText}</Text>
|
<Text style={styles.aboutValue}>{localDaemonVersionText}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -140,16 +140,22 @@ export function findLikelyLocalDaemonHost(daemons: HostProfile[]): HostProfile |
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const localhostDaemon = daemons.find((daemon) =>
|
const localhostDaemon = daemons.find((daemon) => isLikelyLocalHost(daemon))
|
||||||
daemon.connections.some(
|
|
||||||
(connection) =>
|
|
||||||
connection.type === 'direct' && isLikelyLocalDirectEndpoint(connection.endpoint)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return localhostDaemon ?? daemons[0] ?? null
|
return localhostDaemon ?? daemons[0] ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isLikelyLocalHost(host: HostProfile | null | undefined): boolean {
|
||||||
|
if (!host) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return host.connections.some(
|
||||||
|
(connection) =>
|
||||||
|
connection.type === 'direct' && isLikelyLocalDirectEndpoint(connection.endpoint)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function buildDaemonUpdateDiagnostics(result: LocalDaemonUpdateResult): string {
|
export function buildDaemonUpdateDiagnostics(result: LocalDaemonUpdateResult): string {
|
||||||
const stdout = result.stdout.length > 0 ? result.stdout : '(empty)'
|
const stdout = result.stdout.length > 0 ? result.stdout : '(empty)'
|
||||||
const stderr = result.stderr.length > 0 ? result.stderr : '(empty)'
|
const stderr = result.stderr.length > 0 ? result.stderr : '(empty)'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useCallback, useRef, useState } from 'react'
|
import { useCallback, useRef, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
checkDesktopAppUpdate,
|
checkDesktopAppUpdate,
|
||||||
|
formatVersionWithPrefix,
|
||||||
installDesktopAppUpdate,
|
installDesktopAppUpdate,
|
||||||
shouldShowDesktopUpdateSection,
|
shouldShowDesktopUpdateSection,
|
||||||
type DesktopAppUpdateCheckResult,
|
type DesktopAppUpdateCheckResult,
|
||||||
@@ -57,7 +58,7 @@ function formatStatusText(input: {
|
|||||||
|
|
||||||
if (status === 'available') {
|
if (status === 'available') {
|
||||||
if (availableUpdate?.latestVersion) {
|
if (availableUpdate?.latestVersion) {
|
||||||
return `Update available: ${availableUpdate.latestVersion}`
|
return `Update available: ${formatVersionWithPrefix(availableUpdate.latestVersion)}`
|
||||||
}
|
}
|
||||||
return 'An app update is available.'
|
return 'An app update is available.'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user