mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-07 19:19:59 +02:00
refactor song path replacement
- path replacement during runtime instead of during API normalization - fix Navidrome API path not appending libraryPath which caused inconsistency between ND and Subsonic paths
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { usePathReplace, useSettingsStore } from '/@/renderer/store/settings.store';
|
||||
import { replacePathPrefix } from '/@/shared/api/utils';
|
||||
|
||||
export const resolveSongPath = (path: null | string | undefined): null | string => {
|
||||
if (!path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { pathReplace, pathReplaceWith } = useSettingsStore.getState().general;
|
||||
|
||||
return replacePathPrefix(path, pathReplace, pathReplaceWith);
|
||||
};
|
||||
|
||||
export const useResolvedSongPath = (path: null | string | undefined): null | string => {
|
||||
const { pathReplace, pathReplaceWith } = usePathReplace();
|
||||
|
||||
return useMemo(() => {
|
||||
if (!path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return replacePathPrefix(path, pathReplace, pathReplaceWith);
|
||||
}, [path, pathReplace, pathReplaceWith]);
|
||||
};
|
||||
Reference in New Issue
Block a user