From 7ae259cacf2762f092c864655efeacd928bbb04c Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 30 Jun 2026 20:03:25 +0200 Subject: [PATCH] refactor(updater,settings): move feature-owned updater + theme-update hooks into their features --- src/features/settings/components/InstalledThemes.tsx | 4 ++-- src/features/settings/components/ThemeStoreSection.tsx | 2 +- src/features/settings/components/ThemeUpdateBanner.tsx | 2 +- .../settings}/hooks/useThemeAnimationRisk.ts | 0 src/{ => features/settings}/hooks/useThemeUpdates.test.ts | 8 ++++---- src/{ => features/settings}/hooks/useThemeUpdates.ts | 6 +++--- src/features/updater/components/AppUpdater.tsx | 2 +- src/{ => features/updater}/hooks/useAppUpdater.ts | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) rename src/{ => features/settings}/hooks/useThemeAnimationRisk.ts (100%) rename src/{ => features/settings}/hooks/useThemeUpdates.test.ts (90%) rename src/{ => features/settings}/hooks/useThemeUpdates.ts (91%) rename src/{ => features/updater}/hooks/useAppUpdater.ts (98%) diff --git a/src/features/settings/components/InstalledThemes.tsx b/src/features/settings/components/InstalledThemes.tsx index 8e396c6f..786b035b 100644 --- a/src/features/settings/components/InstalledThemes.tsx +++ b/src/features/settings/components/InstalledThemes.tsx @@ -5,8 +5,8 @@ import { useThemeStore } from '@/store/themeStore'; import { useInstalledThemesStore } from '@/store/installedThemesStore'; import { uninstallTheme } from '@/utils/themes/uninstallTheme'; import { installThemeFromRegistry } from '@/utils/themes/installThemeFromRegistry'; -import { useThemeUpdates } from '@/hooks/useThemeUpdates'; -import { useThemeAnimationRisk } from '@/hooks/useThemeAnimationRisk'; +import { useThemeUpdates } from '@/features/settings/hooks/useThemeUpdates'; +import { useThemeAnimationRisk } from '@/features/settings/hooks/useThemeAnimationRisk'; import { showToast } from '@/utils/ui/toast'; import { AnimatedThemeBadge } from '@/features/settings/components/AnimatedThemeBadge'; import { FIXED_THEMES } from '@/utils/themes/fixedThemes'; diff --git a/src/features/settings/components/ThemeStoreSection.tsx b/src/features/settings/components/ThemeStoreSection.tsx index 8b80d296..7738fdca 100644 --- a/src/features/settings/components/ThemeStoreSection.tsx +++ b/src/features/settings/components/ThemeStoreSection.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { Check, ChevronLeft, ChevronRight, Download, RefreshCw, Trash2, WifiOff } from 'lucide-react'; import { open as openUrl } from '@tauri-apps/plugin-shell'; import CoverLightbox from '@/ui/CoverLightbox'; -import { useThemeAnimationRisk } from '@/hooks/useThemeAnimationRisk'; +import { useThemeAnimationRisk } from '@/features/settings/hooks/useThemeAnimationRisk'; import { AnimatedThemeBadge } from '@/features/settings/components/AnimatedThemeBadge'; import CustomSelect from '@/ui/CustomSelect'; import { formatRelativeTime } from '@/lib/format/relativeTime'; diff --git a/src/features/settings/components/ThemeUpdateBanner.tsx b/src/features/settings/components/ThemeUpdateBanner.tsx index a9184ce5..9ca203fe 100644 --- a/src/features/settings/components/ThemeUpdateBanner.tsx +++ b/src/features/settings/components/ThemeUpdateBanner.tsx @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'; import { Paintbrush, X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { useAuthStore } from '@/store/authStore'; -import { useThemeUpdates, themeUpdateSignature } from '@/hooks/useThemeUpdates'; +import { useThemeUpdates, themeUpdateSignature } from '@/features/settings/hooks/useThemeUpdates'; interface Props { collapsed?: boolean; diff --git a/src/hooks/useThemeAnimationRisk.ts b/src/features/settings/hooks/useThemeAnimationRisk.ts similarity index 100% rename from src/hooks/useThemeAnimationRisk.ts rename to src/features/settings/hooks/useThemeAnimationRisk.ts diff --git a/src/hooks/useThemeUpdates.test.ts b/src/features/settings/hooks/useThemeUpdates.test.ts similarity index 90% rename from src/hooks/useThemeUpdates.test.ts rename to src/features/settings/hooks/useThemeUpdates.test.ts index dbae00e7..cd7def54 100644 --- a/src/hooks/useThemeUpdates.test.ts +++ b/src/features/settings/hooks/useThemeUpdates.test.ts @@ -1,14 +1,14 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { renderHook, waitFor } from '@testing-library/react'; -vi.mock('../utils/themes/themeRegistry', () => ({ +vi.mock('@/utils/themes/themeRegistry', () => ({ fetchRegistry: vi.fn(), getCachedRegistry: vi.fn(() => null), })); -import { fetchRegistry, type Registry } from '../utils/themes/themeRegistry'; -import { useInstalledThemesStore, type InstalledTheme } from '../store/installedThemesStore'; -import { useThemeUpdates, themeUpdateSignature } from './useThemeUpdates'; +import { fetchRegistry, type Registry } from '@/utils/themes/themeRegistry'; +import { useInstalledThemesStore, type InstalledTheme } from '@/store/installedThemesStore'; +import { useThemeUpdates, themeUpdateSignature } from '@/features/settings/hooks/useThemeUpdates'; const fetchRegistryMock = vi.mocked(fetchRegistry); diff --git a/src/hooks/useThemeUpdates.ts b/src/features/settings/hooks/useThemeUpdates.ts similarity index 91% rename from src/hooks/useThemeUpdates.ts rename to src/features/settings/hooks/useThemeUpdates.ts index cec9dd3e..e249979d 100644 --- a/src/hooks/useThemeUpdates.ts +++ b/src/features/settings/hooks/useThemeUpdates.ts @@ -1,7 +1,7 @@ import { useEffect, useMemo, useState } from 'react'; -import { isNewer } from '../utils/componentHelpers/appUpdaterHelpers'; -import { fetchRegistry, getCachedRegistry, type Registry, type RegistryTheme } from '../utils/themes/themeRegistry'; -import { useInstalledThemesStore } from '../store/installedThemesStore'; +import { isNewer } from '@/utils/componentHelpers/appUpdaterHelpers'; +import { fetchRegistry, getCachedRegistry, type Registry, type RegistryTheme } from '@/utils/themes/themeRegistry'; +import { useInstalledThemesStore } from '@/store/installedThemesStore'; // Refresh the registry from source once per app launch (not just from the // cache). This surfaces newly published themes and updates without the user diff --git a/src/features/updater/components/AppUpdater.tsx b/src/features/updater/components/AppUpdater.tsx index 1e6ef549..4394dfca 100644 --- a/src/features/updater/components/AppUpdater.tsx +++ b/src/features/updater/components/AppUpdater.tsx @@ -4,7 +4,7 @@ import { ArrowUpCircle, CheckCircle2, ChevronDown, Download, FolderOpen, Refresh import { useTranslation } from 'react-i18next'; import { version as currentVersion } from '@/../package.json'; import { formatBytes } from '@/lib/format/formatBytes'; -import { useAppUpdater } from '@/hooks/useAppUpdater'; +import { useAppUpdater } from '@/features/updater/hooks/useAppUpdater'; import Modal from '@/components/Modal'; import Changelog from '@/features/updater/components/Changelog'; diff --git a/src/hooks/useAppUpdater.ts b/src/features/updater/hooks/useAppUpdater.ts similarity index 98% rename from src/hooks/useAppUpdater.ts rename to src/features/updater/hooks/useAppUpdater.ts index cbea8005..2b99aac5 100644 --- a/src/hooks/useAppUpdater.ts +++ b/src/features/updater/hooks/useAppUpdater.ts @@ -3,9 +3,9 @@ import { listen } from '@tauri-apps/api/event'; import { dirname } from '@tauri-apps/api/path'; import { invoke } from '@tauri-apps/api/core'; import { useTranslation } from 'react-i18next'; -import { version as currentVersion } from '../../package.json'; +import { version as currentVersion } from '../../../../package.json'; import { IS_LINUX, IS_MACOS, IS_WINDOWS } from '@/lib/util/platform'; -import { SKIP_KEY, isNewer, isWithinModerationWindow, pickAsset, type ReleaseData, type DlState } from '../utils/componentHelpers/appUpdaterHelpers'; +import { SKIP_KEY, isNewer, isWithinModerationWindow, pickAsset, type ReleaseData, type DlState } from '@/utils/componentHelpers/appUpdaterHelpers'; /** All update-modal state, the GitHub release probe and the download/relaunch * handlers. The component owns only the early-return guard and the JSX. */