From 650bd917736feb499b83e3ee740437a4ea498315 Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:25:38 +0200 Subject: [PATCH] debug actions in /About screen Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com> --- src/pages/Settings.tsx | 165 ++++++++++++++++++++++++++++++++--------- 1 file changed, 132 insertions(+), 33 deletions(-) diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index dd682c8..99170c3 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -3,6 +3,7 @@ import { Card, CardBody, Checkbox, + Chip, Dropdown, DropdownItem, DropdownMenu, @@ -27,8 +28,8 @@ import { getCurrentWindow } from '@tauri-apps/api/window' import { disable, enable } from '@tauri-apps/plugin-autostart' import { writeText } from '@tauri-apps/plugin-clipboard-manager' import { ask, message } from '@tauri-apps/plugin-dialog' -import { remove } from '@tauri-apps/plugin-fs' -import { openUrl } from '@tauri-apps/plugin-opener' +import { readTextFileLines, remove } from '@tauri-apps/plugin-fs' +import { openUrl, revealItemInDir } from '@tauri-apps/plugin-opener' import { version as osVersion, type } from '@tauri-apps/plugin-os' import { relaunch } from '@tauri-apps/plugin-process' import { type Update, check } from '@tauri-apps/plugin-updater' @@ -36,7 +37,6 @@ import { CheckIcon, CodeIcon, CogIcon, - CopyIcon, EyeIcon, ImportIcon, InfoIcon, @@ -51,6 +51,7 @@ import { type HTMLAttributes, useCallback, useEffect, + useRef, useState, } from 'react' import { revokeMachineLicense, validateLicense } from '../../lib/license' @@ -449,14 +450,15 @@ function GeneralSection() { } try { + setStartOnBoot(value) + if (value) { await enable() } else { await disable() } - - setStartOnBoot(value) } catch (error) { + setStartOnBoot(!value) await message( `An error occurred while toggling start on boot. ${error}`, { @@ -467,7 +469,12 @@ function GeneralSection() { } }} > - Start on boot +
+

Start on boot

+ + New + +
([]) const fetchInfo = useCallback(async () => { const defaultPaths = await getDefaultPaths() @@ -1146,17 +1154,129 @@ function AboutSection() { } }, [currentConfig]) + const fetchLogs = useCallback(async (logFilePath: string) => { + if (isLoadingLogs.current) { + return [] + } + isLoadingLogs.current = true + const logLines = await readTextFileLines(logFilePath) + const lines = [] + for await (const line of logLines) { + lines.push(line) + } + isLoadingLogs.current = false + return lines.slice(-30) + }, []) + useEffect(() => { fetchInfo().then(setInfo) }, [fetchInfo]) + useEffect(() => { + if (!info) { + return + } + if (last30Lines.length > 0) { + return + } + fetchLogs(info.dirs.appLog + '/Rclone UI.log').then(setLast30Lines) + }, [fetchLogs, info, last30Lines.length]) + return (
-
- {!info && } - {info && ( + {!info && } + + {info && ( +
+ + + + +
+ )} + + {info && ( +