mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-02 08:39:55 +02:00
61cc87e0b7
- path replacement during runtime instead of during API normalization - fix Navidrome API path not appending libraryPath which caused inconsistency between ND and Subsonic paths
27 lines
816 B
TypeScript
27 lines
816 B
TypeScript
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]);
|
|
};
|