mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 04:51:06 +02:00
refactor feature hooks to be conditionally initialized
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import IcecastMetadataStats from 'icecast-metadata-stats';
|
||||
import isElectron from 'is-electron';
|
||||
import { useEffect } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { createWithEqualityFn } from 'zustand/traditional';
|
||||
|
||||
import { usePlayerEvents } from '/@/renderer/features/player/audio-player/hooks/use-player-events';
|
||||
@@ -287,3 +287,33 @@ export const useRadioMetadata = () => {
|
||||
};
|
||||
}, [currentStreamUrl, setMetadata, isUsingMpv]);
|
||||
};
|
||||
|
||||
const RadioAudioInstanceHookInner = () => {
|
||||
useRadioAudioInstance();
|
||||
return null;
|
||||
};
|
||||
|
||||
export const RadioAudioInstanceHook = () => {
|
||||
const isRadioActive = useIsRadioActive();
|
||||
|
||||
if (!isRadioActive) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return React.createElement(RadioAudioInstanceHookInner);
|
||||
};
|
||||
|
||||
const RadioMetadataHookInner = () => {
|
||||
useRadioMetadata();
|
||||
return null;
|
||||
};
|
||||
|
||||
export const RadioMetadataHook = () => {
|
||||
const isRadioActive = useIsRadioActive();
|
||||
|
||||
if (!isRadioActive) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return React.createElement(RadioMetadataHookInner);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user