mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 23:35:44 +00:00
refactor(updater,settings): move feature-owned updater + theme-update hooks into their features
This commit is contained in:
@@ -5,8 +5,8 @@ import { useThemeStore } from '@/store/themeStore';
|
|||||||
import { useInstalledThemesStore } from '@/store/installedThemesStore';
|
import { useInstalledThemesStore } from '@/store/installedThemesStore';
|
||||||
import { uninstallTheme } from '@/utils/themes/uninstallTheme';
|
import { uninstallTheme } from '@/utils/themes/uninstallTheme';
|
||||||
import { installThemeFromRegistry } from '@/utils/themes/installThemeFromRegistry';
|
import { installThemeFromRegistry } from '@/utils/themes/installThemeFromRegistry';
|
||||||
import { useThemeUpdates } from '@/hooks/useThemeUpdates';
|
import { useThemeUpdates } from '@/features/settings/hooks/useThemeUpdates';
|
||||||
import { useThemeAnimationRisk } from '@/hooks/useThemeAnimationRisk';
|
import { useThemeAnimationRisk } from '@/features/settings/hooks/useThemeAnimationRisk';
|
||||||
import { showToast } from '@/utils/ui/toast';
|
import { showToast } from '@/utils/ui/toast';
|
||||||
import { AnimatedThemeBadge } from '@/features/settings/components/AnimatedThemeBadge';
|
import { AnimatedThemeBadge } from '@/features/settings/components/AnimatedThemeBadge';
|
||||||
import { FIXED_THEMES } from '@/utils/themes/fixedThemes';
|
import { FIXED_THEMES } from '@/utils/themes/fixedThemes';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { Check, ChevronLeft, ChevronRight, Download, RefreshCw, Trash2, WifiOff } from 'lucide-react';
|
import { Check, ChevronLeft, ChevronRight, Download, RefreshCw, Trash2, WifiOff } from 'lucide-react';
|
||||||
import { open as openUrl } from '@tauri-apps/plugin-shell';
|
import { open as openUrl } from '@tauri-apps/plugin-shell';
|
||||||
import CoverLightbox from '@/ui/CoverLightbox';
|
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 { AnimatedThemeBadge } from '@/features/settings/components/AnimatedThemeBadge';
|
||||||
import CustomSelect from '@/ui/CustomSelect';
|
import CustomSelect from '@/ui/CustomSelect';
|
||||||
import { formatRelativeTime } from '@/lib/format/relativeTime';
|
import { formatRelativeTime } from '@/lib/format/relativeTime';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { Paintbrush, X } from 'lucide-react';
|
import { Paintbrush, X } from 'lucide-react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAuthStore } from '@/store/authStore';
|
import { useAuthStore } from '@/store/authStore';
|
||||||
import { useThemeUpdates, themeUpdateSignature } from '@/hooks/useThemeUpdates';
|
import { useThemeUpdates, themeUpdateSignature } from '@/features/settings/hooks/useThemeUpdates';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
collapsed?: boolean;
|
collapsed?: boolean;
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { renderHook, waitFor } from '@testing-library/react';
|
import { renderHook, waitFor } from '@testing-library/react';
|
||||||
|
|
||||||
vi.mock('../utils/themes/themeRegistry', () => ({
|
vi.mock('@/utils/themes/themeRegistry', () => ({
|
||||||
fetchRegistry: vi.fn(),
|
fetchRegistry: vi.fn(),
|
||||||
getCachedRegistry: vi.fn(() => null),
|
getCachedRegistry: vi.fn(() => null),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import { fetchRegistry, type Registry } from '../utils/themes/themeRegistry';
|
import { fetchRegistry, type Registry } from '@/utils/themes/themeRegistry';
|
||||||
import { useInstalledThemesStore, type InstalledTheme } from '../store/installedThemesStore';
|
import { useInstalledThemesStore, type InstalledTheme } from '@/store/installedThemesStore';
|
||||||
import { useThemeUpdates, themeUpdateSignature } from './useThemeUpdates';
|
import { useThemeUpdates, themeUpdateSignature } from '@/features/settings/hooks/useThemeUpdates';
|
||||||
|
|
||||||
const fetchRegistryMock = vi.mocked(fetchRegistry);
|
const fetchRegistryMock = vi.mocked(fetchRegistry);
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { isNewer } from '../utils/componentHelpers/appUpdaterHelpers';
|
import { isNewer } from '@/utils/componentHelpers/appUpdaterHelpers';
|
||||||
import { fetchRegistry, getCachedRegistry, type Registry, type RegistryTheme } from '../utils/themes/themeRegistry';
|
import { fetchRegistry, getCachedRegistry, type Registry, type RegistryTheme } from '@/utils/themes/themeRegistry';
|
||||||
import { useInstalledThemesStore } from '../store/installedThemesStore';
|
import { useInstalledThemesStore } from '@/store/installedThemesStore';
|
||||||
|
|
||||||
// Refresh the registry from source once per app launch (not just from the
|
// Refresh the registry from source once per app launch (not just from the
|
||||||
// cache). This surfaces newly published themes and updates without the user
|
// cache). This surfaces newly published themes and updates without the user
|
||||||
@@ -4,7 +4,7 @@ import { ArrowUpCircle, CheckCircle2, ChevronDown, Download, FolderOpen, Refresh
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { version as currentVersion } from '@/../package.json';
|
import { version as currentVersion } from '@/../package.json';
|
||||||
import { formatBytes } from '@/lib/format/formatBytes';
|
import { formatBytes } from '@/lib/format/formatBytes';
|
||||||
import { useAppUpdater } from '@/hooks/useAppUpdater';
|
import { useAppUpdater } from '@/features/updater/hooks/useAppUpdater';
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import Changelog from '@/features/updater/components/Changelog';
|
import Changelog from '@/features/updater/components/Changelog';
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { listen } from '@tauri-apps/api/event';
|
|||||||
import { dirname } from '@tauri-apps/api/path';
|
import { dirname } from '@tauri-apps/api/path';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
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 { 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
|
/** All update-modal state, the GitHub release probe and the download/relaunch
|
||||||
* handlers. The component owns only the early-return guard and the JSX. */
|
* handlers. The component owns only the early-return guard and the JSX. */
|
||||||
Reference in New Issue
Block a user