mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-16 00:14:23 +02:00
reverse the lyrics offset behavior to standard convention
This commit is contained in:
@@ -73,6 +73,7 @@
|
|||||||
"enable": "enable",
|
"enable": "enable",
|
||||||
"expand": "expand",
|
"expand": "expand",
|
||||||
"externalLinks": "external links",
|
"externalLinks": "external links",
|
||||||
|
"faster": "faster",
|
||||||
"favorite": "favorite",
|
"favorite": "favorite",
|
||||||
"filter_one": "filter",
|
"filter_one": "filter",
|
||||||
"filter_other": "filters",
|
"filter_other": "filters",
|
||||||
@@ -122,6 +123,7 @@
|
|||||||
"setting": "setting",
|
"setting": "setting",
|
||||||
"setting_one": "setting",
|
"setting_one": "setting",
|
||||||
"setting_other": "settings",
|
"setting_other": "settings",
|
||||||
|
"slower": "slower",
|
||||||
"share": "share",
|
"share": "share",
|
||||||
"size": "size",
|
"size": "size",
|
||||||
"sort": "sort",
|
"sort": "sort",
|
||||||
|
|||||||
@@ -20,19 +20,17 @@ import { LyricsOverride } from '/@/shared/types/domain-types';
|
|||||||
interface LyricsActionsProps {
|
interface LyricsActionsProps {
|
||||||
index: number;
|
index: number;
|
||||||
languages: { label: string; value: string }[];
|
languages: { label: string; value: string }[];
|
||||||
|
|
||||||
onRemoveLyric: () => void;
|
onRemoveLyric: () => void;
|
||||||
onResetLyric: () => void;
|
|
||||||
onSearchOverride: (params: LyricsOverride) => void;
|
onSearchOverride: (params: LyricsOverride) => void;
|
||||||
onTranslateLyric?: () => void;
|
onTranslateLyric?: () => void;
|
||||||
setIndex: (idx: number) => void;
|
setIndex: (idx: number) => void;
|
||||||
|
synced?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LyricsActions = ({
|
export const LyricsActions = ({
|
||||||
index,
|
index,
|
||||||
languages,
|
languages,
|
||||||
onRemoveLyric,
|
onRemoveLyric,
|
||||||
onResetLyric,
|
|
||||||
onSearchOverride,
|
onSearchOverride,
|
||||||
onTranslateLyric,
|
onTranslateLyric,
|
||||||
setIndex,
|
setIndex,
|
||||||
@@ -89,39 +87,34 @@ export const LyricsActions = ({
|
|||||||
aria-label="Decrease lyric offset"
|
aria-label="Decrease lyric offset"
|
||||||
icon="minus"
|
icon="minus"
|
||||||
onClick={() => handleLyricOffset(delayMs - 50)}
|
onClick={() => handleLyricOffset(delayMs - 50)}
|
||||||
|
tooltip={{
|
||||||
|
label: t('common.slower', { postProcess: 'sentenceCase' }),
|
||||||
|
openDelay: 0,
|
||||||
|
}}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t('setting.lyricOffset', { postProcess: 'sentenceCase' })}
|
label={t('setting.lyricOffset', { postProcess: 'sentenceCase' })}
|
||||||
openDelay={500}
|
openDelay={0}
|
||||||
>
|
>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
aria-label="Lyric offset"
|
aria-label="Lyric offset"
|
||||||
onChange={handleLyricOffset}
|
onChange={handleLyricOffset}
|
||||||
styles={{ input: { textAlign: 'center' } }}
|
styles={{ input: { textAlign: 'center' } }}
|
||||||
value={delayMs || 0}
|
value={delayMs || 0}
|
||||||
width={55}
|
width={70}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
aria-label="Increase lyric offset"
|
aria-label="Increase lyric offset"
|
||||||
icon="plus"
|
icon="plus"
|
||||||
onClick={() => handleLyricOffset(delayMs + 50)}
|
onClick={() => handleLyricOffset(delayMs + 50)}
|
||||||
|
tooltip={{
|
||||||
|
label: t('common.faster', { postProcess: 'sentenceCase' }),
|
||||||
|
openDelay: 0,
|
||||||
|
}}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
/>
|
/>
|
||||||
{isDesktop && sources.length ? (
|
|
||||||
<Button
|
|
||||||
disabled={isActionsDisabled}
|
|
||||||
onClick={onResetLyric}
|
|
||||||
uppercase
|
|
||||||
variant="subtle"
|
|
||||||
>
|
|
||||||
{t('common.reset', { postProcess: 'sentenceCase' })}
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
<div style={{ position: 'absolute', right: 0, top: 0 }}>
|
|
||||||
{isDesktop && sources.length ? (
|
{isDesktop && sources.length ? (
|
||||||
<Button
|
<Button
|
||||||
disabled={isActionsDisabled}
|
disabled={isActionsDisabled}
|
||||||
@@ -132,7 +125,7 @@ export const LyricsActions = ({
|
|||||||
{t('common.clear', { postProcess: 'sentenceCase' })}
|
{t('common.clear', { postProcess: 'sentenceCase' })}
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</Group>
|
||||||
|
|
||||||
<div style={{ position: 'absolute', right: 0, top: -50 }}>
|
<div style={{ position: 'absolute', right: 0, top: -50 }}>
|
||||||
{isDesktop && sources.length && onTranslateLyric ? (
|
{isDesktop && sources.length && onTranslateLyric ? (
|
||||||
|
|||||||
@@ -114,13 +114,13 @@ export const Lyrics = () => {
|
|||||||
}
|
}
|
||||||
}, [override, overrideData, currentSong]);
|
}, [override, overrideData, currentSong]);
|
||||||
|
|
||||||
const handleOnResetLyric = useCallback(() => {
|
// const handleOnResetLyric = useCallback(() => {
|
||||||
setOverride(undefined);
|
// setOverride(undefined);
|
||||||
queryClient.invalidateQueries({
|
// queryClient.invalidateQueries({
|
||||||
exact: true,
|
// exact: true,
|
||||||
queryKey: queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
// queryKey: queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
||||||
});
|
// });
|
||||||
}, [currentSong?.id, currentSong?._serverId]);
|
// }, [currentSong?.id, currentSong?._serverId]);
|
||||||
|
|
||||||
const handleOnRemoveLyric = useCallback(() => {
|
const handleOnRemoveLyric = useCallback(() => {
|
||||||
queryClient.setQueryData(
|
queryClient.setQueryData(
|
||||||
@@ -259,7 +259,6 @@ export const Lyrics = () => {
|
|||||||
index={index}
|
index={index}
|
||||||
languages={languages}
|
languages={languages}
|
||||||
onRemoveLyric={handleOnRemoveLyric}
|
onRemoveLyric={handleOnRemoveLyric}
|
||||||
onResetLyric={handleOnResetLyric}
|
|
||||||
onSearchOverride={handleOnSearchOverride}
|
onSearchOverride={handleOnSearchOverride}
|
||||||
onTranslateLyric={
|
onTranslateLyric={
|
||||||
translationApiProvider && translationApiKey
|
translationApiProvider && translationApiKey
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ export const SynchronizedLyrics = ({
|
|||||||
|
|
||||||
if (status === PlayerStatus.PLAYING) {
|
if (status === PlayerStatus.PLAYING) {
|
||||||
// Use the current timestamp from player events
|
// Use the current timestamp from player events
|
||||||
setCurrentLyric(timestamp * 1000 - delayMsRef.current);
|
setCurrentLyric(timestamp * 1000 + delayMsRef.current);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
// Cleanup: clear the timer when lyrics change or component unmounts
|
// Cleanup: clear the timer when lyrics change or component unmounts
|
||||||
@@ -208,7 +208,7 @@ export const SynchronizedLyrics = ({
|
|||||||
delayMsRef.current = settings.delayMs;
|
delayMsRef.current = settings.delayMs;
|
||||||
|
|
||||||
// Use the current timestamp from player events
|
// Use the current timestamp from player events
|
||||||
setCurrentLyric(timestamp * 1000 - delayMsRef.current);
|
setCurrentLyric(timestamp * 1000 + delayMsRef.current);
|
||||||
}, [setCurrentLyric, settings.delayMs, timestamp]);
|
}, [setCurrentLyric, settings.delayMs, timestamp]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -226,7 +226,7 @@ export const SynchronizedLyrics = ({
|
|||||||
clearTimeout(lyricTimer.current);
|
clearTimeout(lyricTimer.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentLyric(timestamp * 1000 - delayMsRef.current);
|
setCurrentLyric(timestamp * 1000 + delayMsRef.current);
|
||||||
}, [timestamp, setCurrentLyric, status]);
|
}, [timestamp, setCurrentLyric, status]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user