mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
refactor(api): F.50 — extract 7 small domain modules (#615)
Seven domain-eng splits peel ~200 LOC of read endpoints out of `api/subsonic.ts`: - `subsonicStreamUrl.ts` — `buildStreamUrl`, `coverArtCacheKey`, `buildCoverArtUrl`, `buildDownloadUrl` (token-signed URL builders for the four /rest endpoints we hand to the browser). - `subsonicStarRating.ts` — `getStarred`, `star`, `unstar`, `setRating`, `probeEntityRatingSupport`. `setRating` still triggers the lazy `navidromeBrowse` cache invalidation; the same-folder lazy import path is preserved. - `subsonicSearch.ts` — `search`, `searchSongsPaged`. - `subsonicScrobble.ts` — `scrobbleSong`, `reportNowPlaying`, `getNowPlaying`. - `subsonicAlbumInfo.ts` — `getAlbumInfo2`. - `subsonicLyrics.ts` — `getLyricsBySongId`. - `subsonicGenres.ts` — `getGenres`, `getAlbumsByGenre`. 63 external call sites migrated to direct imports. Four `vi.mock` targets in the store-level tests pointed at `../api/subsonic` and were updated to the new module paths. Pure code-move. subsonic.ts: 762 → 561 LOC (−201).
This commit is contained in:
committed by
GitHub
parent
006635de4b
commit
9606a99efb
@@ -1,5 +1,5 @@
|
||||
import { reportNowPlaying } from '../api/subsonicScrobble';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { reportNowPlaying } from '../api/subsonic';
|
||||
import { getPlaybackSourceKind } from '../utils/resolvePlaybackUrl';
|
||||
import { useAuthStore } from './authStore';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { reportNowPlaying, scrobbleSong } from '../api/subsonicScrobble';
|
||||
import type { Track } from './playerStoreTypes';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { lastfmGetTrackLoved, lastfmScrobble, lastfmUpdateNowPlaying } from '../api/lastfm';
|
||||
import { reportNowPlaying, scrobbleSong } from '../api/subsonic';
|
||||
import { setDeferHotCachePrefetch } from '../utils/hotCacheGate';
|
||||
import { getPerfProbeFlags } from '../utils/perfFlags';
|
||||
import { bumpPerfCounter } from '../utils/perfTelemetry';
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { getAlbumInfo2 } from '../api/subsonicAlbumInfo';
|
||||
import { buildCoverArtUrl } from '../api/subsonicStreamUrl';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import {
|
||||
buildCoverArtUrl,
|
||||
getAlbumInfo2,
|
||||
} from '../api/subsonic';
|
||||
import { streamUrlTrackId } from '../utils/resolvePlaybackUrl';
|
||||
import { effectiveLoudnessPreAnalysisAttenuationDb } from '../utils/loudnessPreAnalysisSlider';
|
||||
import { normalizationAlmostEqual } from '../utils/normalizationCompare';
|
||||
|
||||
@@ -38,7 +38,7 @@ const hoisted = vi.hoisted(() => {
|
||||
});
|
||||
|
||||
vi.mock('@tauri-apps/api/core', () => ({ invoke: hoisted.invokeMock }));
|
||||
vi.mock('../api/subsonic', () => ({ buildStreamUrl: hoisted.buildStreamUrlMock }));
|
||||
vi.mock('../api/subsonicStreamUrl', () => ({ buildStreamUrl: hoisted.buildStreamUrlMock }));
|
||||
vi.mock('../utils/redactSubsonicUrl', () => ({ redactSubsonicUrlForLog: hoisted.redactMock }));
|
||||
vi.mock('./authStore', () => ({ useAuthStore: { getState: () => hoisted.auth } }));
|
||||
vi.mock('./playerStore', () => ({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { buildStreamUrl } from '../api/subsonicStreamUrl';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { buildStreamUrl } from '../api/subsonic';
|
||||
import { redactSubsonicUrlForLog } from '../utils/redactSubsonicUrl';
|
||||
import { useAuthStore } from './authStore';
|
||||
import { usePlayerStore } from './playerStore';
|
||||
|
||||
@@ -31,7 +31,7 @@ const hoisted = vi.hoisted(() => {
|
||||
});
|
||||
|
||||
vi.mock('@tauri-apps/api/core', () => ({ invoke: hoisted.invokeMock }));
|
||||
vi.mock('../api/subsonic', () => ({ buildStreamUrl: hoisted.buildStreamUrlMock }));
|
||||
vi.mock('../api/subsonicStreamUrl', () => ({ buildStreamUrl: hoisted.buildStreamUrlMock }));
|
||||
vi.mock('./authStore', () => ({ useAuthStore: { getState: () => hoisted.authState } }));
|
||||
vi.mock('./playerStore', () => ({
|
||||
usePlayerStore: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { buildStreamUrl } from '../api/subsonicStreamUrl';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { buildStreamUrl } from '../api/subsonic';
|
||||
import { useAuthStore } from './authStore';
|
||||
import { usePlayerStore } from './playerStore';
|
||||
import { bumpWaveformRefreshGen } from './waveformRefreshGen';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { buildStreamUrl } from '../api/subsonicStreamUrl';
|
||||
import { getAlbum } from '../api/subsonicLibrary';
|
||||
import { getArtist } from '../api/subsonicArtists';
|
||||
import type { SubsonicSong } from '../api/subsonicTypes';
|
||||
import { create } from 'zustand';
|
||||
import { persist, createJSONStorage } from 'zustand/middleware';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { buildStreamUrl } from '../api/subsonic';
|
||||
import { useAuthStore } from './authStore';
|
||||
import { showToast } from '../utils/toast';
|
||||
import { useOfflineJobStore, cancelledDownloads } from './offlineJobStore';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { reportNowPlaying } from '../api/subsonicScrobble';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { lastfmGetTrackLoved, lastfmUpdateNowPlaying } from '../api/lastfm';
|
||||
import { reportNowPlaying } from '../api/subsonic';
|
||||
import { setDeferHotCachePrefetch } from '../utils/hotCacheGate';
|
||||
import { orbitBulkGuard } from '../utils/orbitBulkGuard';
|
||||
import { sameQueueTrackId } from '../utils/queueIdentity';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { buildStreamUrl } from '../api/subsonicStreamUrl';
|
||||
import type { TrackPreviewLocation } from './authStoreTypes';
|
||||
import { create } from 'zustand';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { buildStreamUrl } from '../api/subsonic';
|
||||
import { usePlayerStore } from './playerStore';
|
||||
import { useAuthStore } from './authStore';
|
||||
import { useOrbitStore } from './orbitStore';
|
||||
|
||||
@@ -13,7 +13,7 @@ const { invokeMock, setEntryMock, buildStreamUrlMock } = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock }));
|
||||
vi.mock('../api/subsonic', () => ({ buildStreamUrl: buildStreamUrlMock }));
|
||||
vi.mock('../api/subsonicStreamUrl', () => ({ buildStreamUrl: buildStreamUrlMock }));
|
||||
vi.mock('./hotCacheStore', () => ({
|
||||
useHotCacheStore: { getState: () => ({ setEntry: setEntryMock }) },
|
||||
}));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { buildStreamUrl } from '../api/subsonicStreamUrl';
|
||||
import type { Track } from './playerStoreTypes';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { buildStreamUrl } from '../api/subsonic';
|
||||
import { useHotCacheStore } from './hotCacheStore';
|
||||
/**
|
||||
* Promote a track whose stream cache is full to the on-disk hot cache.
|
||||
|
||||
@@ -23,7 +23,7 @@ const { setRatingMock, recordSkipStarMock, playerSetStateMock, playerStateGet }
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('../api/subsonic', () => ({ setRating: setRatingMock }));
|
||||
vi.mock('../api/subsonicStarRating', () => ({ setRating: setRatingMock }));
|
||||
vi.mock('./authStore', () => ({
|
||||
useAuthStore: { getState: () => ({ recordSkipStarManualAdvance: recordSkipStarMock }) },
|
||||
}));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { setRating } from '../api/subsonicStarRating';
|
||||
import type { Track } from './playerStoreTypes';
|
||||
import { setRating } from '../api/subsonic';
|
||||
import { useAuthStore } from './authStore';
|
||||
import { usePlayerStore } from './playerStore';
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user