mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
refactor(auth): E.44 — extract server-profile + lastfm + audio-settings factories (#609)
Three action-factories peel ~25 setters out of the authStore body, following the playerStore action-factory pattern from Phase E: - `createServerProfileActions` — `addServer`, `updateServer`, `removeServer` (the non-trivial one — drops every per-server map entry for the removed id), `setServers`, `setActiveServer`, `setLoggedIn`, `setConnecting`, `setConnectionError`, `logout`. - `createAuthLastfmActions` — credentials + session connect/disconnect + error flag + master scrobbling toggle. Network calls (love / scrobble) stay in the playerStore-side `lastfmActions.ts`. - `createAudioSettingsActions` — replay-gain / normalization / loudness mode toggles (each calls `usePlayerStore.getState() .updateReplayGainForCurrentTrack()` so a running track catches up), plus crossfade / gapless / hi-res / audio-output (no engine callback needed). Pure code-move; no behaviour change. authStore.ts: 518 → 428 LOC (−90).
This commit is contained in:
committed by
GitHub
parent
4d564e5016
commit
b8ddb09b78
@@ -0,0 +1,35 @@
|
||||
import type { AuthState } from './authStoreTypes';
|
||||
|
||||
type SetState = (
|
||||
partial: Partial<AuthState> | ((state: AuthState) => Partial<AuthState>),
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Last.fm account settings on the auth side: credentials, session
|
||||
* connect/disconnect, error flag, and the master scrobbling toggle.
|
||||
* The actual scrobble/love network calls live in `lastfmActions.ts`
|
||||
* inside the playerStore — these here only manage the persisted
|
||||
* account state.
|
||||
*/
|
||||
export function createAuthLastfmActions(set: SetState): Pick<
|
||||
AuthState,
|
||||
| 'setLastfm'
|
||||
| 'connectLastfm'
|
||||
| 'disconnectLastfm'
|
||||
| 'setLastfmSessionError'
|
||||
| 'setScrobblingEnabled'
|
||||
> {
|
||||
return {
|
||||
setLastfm: (apiKey, apiSecret, sessionKey, username) =>
|
||||
set({ lastfmApiKey: apiKey, lastfmApiSecret: apiSecret, lastfmSessionKey: sessionKey, lastfmUsername: username }),
|
||||
|
||||
connectLastfm: (sessionKey, username) =>
|
||||
set({ lastfmSessionKey: sessionKey, lastfmUsername: username }),
|
||||
|
||||
disconnectLastfm: () =>
|
||||
set({ lastfmSessionKey: '', lastfmUsername: '', lastfmSessionError: false }),
|
||||
|
||||
setLastfmSessionError: (v) => set({ lastfmSessionError: v }),
|
||||
setScrobblingEnabled: (v) => set({ scrobblingEnabled: v }),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user