From 6590bd15eff7f9703843900097199154bbf24063 Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 30 Jun 2026 22:15:46 +0200 Subject: [PATCH] refactor(settings,lib): home licensesData + userMgmtHelpers to owners MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a11y-branch hold lifted (Frank: modals get re-refactored separately, no rebase to protect). Both were only blocked by their modal consumers: - licensesData (pure licenses.json lazy-loader) → features/settings/utils; main consumer is the settings LicensesPanel. JSON dynamic import absolutized to @/data/licenses.json. - userMgmtHelpers (pure formatLastSeen, lib/format only) → lib/format; multi-feature consumer set, same class as playlistDetailHelpers. Drains utils/componentHelpers (dir removed). Only import lines changed in the LicenseTextModal/SongInfoModal consumers (logic untouched); tests pass unmodified. --- src/components/LicenseTextModal.tsx | 2 +- src/components/SongInfoModal.tsx | 2 +- src/features/album/components/TrackRow.tsx | 2 +- src/features/favorites/components/FavoriteSongRow.tsx | 2 +- src/features/playlist/components/PlaylistRow.tsx | 2 +- src/features/playlist/components/PlaylistSuggestions.tsx | 2 +- src/features/settings/components/LicensesPanel.tsx | 2 +- src/features/settings/components/userMgmt/UserMgmtRow.tsx | 2 +- src/{ => features/settings}/utils/licensesData.ts | 2 +- src/{utils/componentHelpers => lib/format}/userMgmtHelpers.ts | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename src/{ => features/settings}/utils/licensesData.ts (97%) rename src/{utils/componentHelpers => lib/format}/userMgmtHelpers.ts (100%) diff --git a/src/components/LicenseTextModal.tsx b/src/components/LicenseTextModal.tsx index b8a96d8b..6b147f34 100644 --- a/src/components/LicenseTextModal.tsx +++ b/src/components/LicenseTextModal.tsx @@ -3,7 +3,7 @@ import { createPortal } from 'react-dom'; import { X, ExternalLink } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { open as openExternal } from '@tauri-apps/plugin-shell'; -import type { LicenseEntry } from '../utils/licensesData'; +import type { LicenseEntry } from '@/features/settings/utils/licensesData'; interface Props { entry: LicenseEntry | null; diff --git a/src/components/SongInfoModal.tsx b/src/components/SongInfoModal.tsx index aa9808b9..5b0479cc 100644 --- a/src/components/SongInfoModal.tsx +++ b/src/components/SongInfoModal.tsx @@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'; import { copyTextToClipboard } from '@/lib/server/serverMagicString'; import { showToast } from '@/lib/dom/toast'; import { formatTrackTime } from '@/lib/format/formatDuration'; -import { formatLastSeen } from '../utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; import { libraryIsReady } from '@/lib/library/libraryReady'; import { formatQueueMoodLabels, diff --git a/src/features/album/components/TrackRow.tsx b/src/features/album/components/TrackRow.tsx index 191b007e..03fe879e 100644 --- a/src/features/album/components/TrackRow.tsx +++ b/src/features/album/components/TrackRow.tsx @@ -12,7 +12,7 @@ import { previewInputFromSong, usePreviewStore } from '@/features/playback/store import StarRating from '@/ui/StarRating'; import { codecLabel, type ColKey } from '@/features/album/utils/albumTrackListHelpers'; import { formatLongDuration } from '@/lib/format/formatDuration'; -import { formatLastSeen } from '@/utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; import i18n from '@/lib/i18n'; import { offlineActionPolicy, type OfflineActionPolicy } from '@/features/offline'; import { resolveTrackArtistRefs } from '@/features/playback/utils/playback/trackArtistRefs'; diff --git a/src/features/favorites/components/FavoriteSongRow.tsx b/src/features/favorites/components/FavoriteSongRow.tsx index 424494a4..db759926 100644 --- a/src/features/favorites/components/FavoriteSongRow.tsx +++ b/src/features/favorites/components/FavoriteSongRow.tsx @@ -4,7 +4,7 @@ import { AudioLines, ChevronRight, Play, Square, X } from 'lucide-react'; import type { ColDef } from '@/hooks/useTracklistColumns'; import type { SubsonicSong } from '@/lib/api/subsonicTypes'; import { codecLabel } from '@/lib/format/playlistDetailHelpers'; -import { formatLastSeen } from '@/utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; import i18n from '@/lib/i18n'; import { formatTrackTime } from '@/lib/format/formatDuration'; import StarRating from '@/ui/StarRating'; diff --git a/src/features/playlist/components/PlaylistRow.tsx b/src/features/playlist/components/PlaylistRow.tsx index e42d366f..ee8ec04e 100644 --- a/src/features/playlist/components/PlaylistRow.tsx +++ b/src/features/playlist/components/PlaylistRow.tsx @@ -4,7 +4,7 @@ import { AudioLines, ChevronRight, Heart, Play, Square, Trash2 } from 'lucide-re import type { ColDef } from '@/hooks/useTracklistColumns'; import type { SubsonicSong } from '@/lib/api/subsonicTypes'; import { codecLabel } from '@/lib/format/playlistDetailHelpers'; -import { formatLastSeen } from '@/utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; import i18n from '@/lib/i18n'; import { formatTrackTime } from '@/lib/format/formatDuration'; import StarRating from '@/ui/StarRating'; diff --git a/src/features/playlist/components/PlaylistSuggestions.tsx b/src/features/playlist/components/PlaylistSuggestions.tsx index 313d379c..4d1eef76 100644 --- a/src/features/playlist/components/PlaylistSuggestions.tsx +++ b/src/features/playlist/components/PlaylistSuggestions.tsx @@ -13,7 +13,7 @@ import { usePlaylistLayoutStore } from '@/features/playlist/store/playlistLayout import { songToTrack } from '@/lib/media/songToTrack'; import { getQueueTracksView } from '@/features/playback/store/queueTrackView'; import { codecLabel } from '@/lib/format/playlistDetailHelpers'; -import { formatLastSeen } from '@/utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; import { formatTrackTime } from '@/lib/format/formatDuration'; import i18n from '@/lib/i18n'; diff --git a/src/features/settings/components/LicensesPanel.tsx b/src/features/settings/components/LicensesPanel.tsx index 00d5b72a..b4b6c7a1 100644 --- a/src/features/settings/components/LicensesPanel.tsx +++ b/src/features/settings/components/LicensesPanel.tsx @@ -8,7 +8,7 @@ import { loadLicensesData, type LicenseEntry, type LicensesData, -} from '@/utils/licensesData'; +} from '@/features/settings/utils/licensesData'; import LicenseTextModal from '@/components/LicenseTextModal'; const ROW_HEIGHT = 56; diff --git a/src/features/settings/components/userMgmt/UserMgmtRow.tsx b/src/features/settings/components/userMgmt/UserMgmtRow.tsx index d4542ec7..20b6974d 100644 --- a/src/features/settings/components/userMgmt/UserMgmtRow.tsx +++ b/src/features/settings/components/userMgmt/UserMgmtRow.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Shield, Trash2, User, Wand2 } from 'lucide-react'; import type { i18n as I18nType, TFunction } from 'i18next'; import type { NdLibrary, NdUser } from '@/lib/api/navidromeAdmin'; -import { formatLastSeen } from '@/utils/componentHelpers/userMgmtHelpers'; +import { formatLastSeen } from '@/lib/format/userMgmtHelpers'; interface Props { user: NdUser; diff --git a/src/utils/licensesData.ts b/src/features/settings/utils/licensesData.ts similarity index 97% rename from src/utils/licensesData.ts rename to src/features/settings/utils/licensesData.ts index 48932d37..5594198e 100644 --- a/src/utils/licensesData.ts +++ b/src/features/settings/utils/licensesData.ts @@ -29,7 +29,7 @@ let cache: Promise | null = null; export function loadLicensesData(): Promise { if (cache) return cache; - cache = import('../data/licenses.json') + cache = import('@/data/licenses.json') .then((mod) => (mod.default ?? mod) as LicensesData) .catch((e) => { cache = null; diff --git a/src/utils/componentHelpers/userMgmtHelpers.ts b/src/lib/format/userMgmtHelpers.ts similarity index 100% rename from src/utils/componentHelpers/userMgmtHelpers.ts rename to src/lib/format/userMgmtHelpers.ts