From 39fca8032cdadfc142d7581972855d107c6e4c5c Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Fri, 28 Feb 2025 18:28:53 +0200 Subject: [PATCH] parse both \ and / (windows) --- src/pages/Jobs.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/pages/Jobs.tsx b/src/pages/Jobs.tsx index 1c52e62..87c139d 100644 --- a/src/pages/Jobs.tsx +++ b/src/pages/Jobs.tsx @@ -2,7 +2,6 @@ import { Card, CardBody, CardFooter, CardHeader } from '@nextui-org/card' import { Button, Chip, Divider, Progress, Spinner } from '@nextui-org/react' import { listen } from '@tauri-apps/api/event' import { ask } from '@tauri-apps/plugin-dialog' -import { platform } from '@tauri-apps/plugin-os' import { Trash2Icon } from 'lucide-react' import { useCallback, useEffect } from 'react' import { useState } from 'react' @@ -30,20 +29,18 @@ export default function Jobs() { setIsInitialLoad(false) }, []) - const buildReadablePath = useCallback((path: string) => { + const buildReadablePath = useCallback((path: string, type: 'short' | 'long' = 'long') => { if (!path) { return '' } - if (path.includes(':')) { - // returns "REMOTE:/.../LAST_SEGMENT" - return `${path.split(':')[0]}:/.../${path.split(':')[1]?.split('/').slice(-1).join('')}` + const lastSegment = path.split('\\').slice(-1).join('').split('/').slice(-1).join('') + + if (type === 'short') { + return lastSegment } - const slashSymbol = platform() === 'windows' ? '\\' : '/' - - // returns "LAST_SEGMENT" - return path.split(slashSymbol).slice(-1).join('') + return `${path.split(':')[0]}:/.../${lastSegment}` }, []) useEffect(() => { @@ -119,7 +116,7 @@ export default function Jobs() {
-
{buildReadablePath(job.srcFs)}
+
{buildReadablePath(job.srcFs, 'short')}
{buildReadablePath(job.dstFs)}
@@ -165,7 +162,7 @@ export default function Jobs() {
-
{buildReadablePath(job.srcFs)}
+
{buildReadablePath(job.srcFs, 'short')}
{buildReadablePath(job.dstFs)}