From cc2a0f284a6ab07943e1a7a033c0b4c4f846c52f Mon Sep 17 00:00:00 2001 From: emirsassan Date: Thu, 10 Jul 2025 09:32:09 +0300 Subject: [PATCH] refactor: move useEffect to /app/cluster and fix icons (again) --- .../frontend/src/routes/app/cluster/index.tsx | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/apps/onelauncher/frontend/src/routes/app/cluster/index.tsx b/apps/onelauncher/frontend/src/routes/app/cluster/index.tsx index 95830969..804f6fe4 100644 --- a/apps/onelauncher/frontend/src/routes/app/cluster/index.tsx +++ b/apps/onelauncher/frontend/src/routes/app/cluster/index.tsx @@ -12,7 +12,7 @@ import { createFileRoute } from '@tanstack/react-router'; import { convertFileSrc } from '@tauri-apps/api/core'; import { open } from '@tauri-apps/plugin-dialog'; import { Edit02Icon, FolderIcon, ImagePlusIcon, Share07Icon, Tool02Icon, Trash01Icon } from '@untitled-theme/icons-react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { twMerge } from 'tailwind-merge'; import Sidebar from '../settings/route'; @@ -38,15 +38,37 @@ function RouteComponent() { }); async function handleEditMode() { - if (edit) { + if (edit) await editing.refetch(); - await cluster.refetch(); - } - setEdit(!edit); } + const { set, remove } = useNotifications(); + + useEffect(() => { + let unlisten: (() => void) | undefined; + (async () => { + unlisten = await bindings.events.ingress.on((e) => { + if (typeof e.ingress_type === 'object') + if ('PrepareCluster' in e.ingress_type) { + const { cluster_name } = e.ingress_type.PrepareCluster; + let cid = `cluster-${cluster_name}`; + + set(cid, { + title: 'Preparing Cluster', + message: e.message, + }); + + if (e.percent === e.total) + remove(cid); + } + }); + })(); + + return () => unlisten?.(); + }, [set, remove]); + return (

Overview

@@ -182,15 +204,11 @@ function Banner({ const url = cluster?.icon_url; - // eslint-disable-next-line no-console -- ok - console.log(url); - if (!url) { console.warn('No icon URL, using default'); return DefaultInstancePhoto; } - console.warn('Using cached icon:', url); return convertFileSrc(url); }; @@ -211,7 +229,7 @@ function Banner({ className="h-full w-full" onError={(e) => { console.error('Failed to load cluster icon:', image(), e); - // (e.target as HTMLImageElement).src = DefaultInstancePhoto; + (e.target as HTMLImageElement).src = DefaultInstancePhoto; }} src={image()} />