Fix seeking (#3096)

* Update apikey when generating/clearing
* Fix seeking on systems with api key
This commit is contained in:
WithoutPants
2022-11-08 13:45:54 +11:00
committed by GitHub
parent 962bc7df4e
commit b9e07ade92
3 changed files with 24 additions and 7 deletions

View File

@@ -397,8 +397,10 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
const sourceSelector = player.sourceSelector(); const sourceSelector = player.sourceSelector();
sourceSelector.setSources( sourceSelector.setSources(
scene.sceneStreams.map((stream) => { scene.sceneStreams.map((stream) => {
const src = new URL(stream.url);
const isDirect = const isDirect =
stream.url.endsWith("/stream") || stream.url.endsWith("/stream.m3u8"); src.pathname.endsWith("/stream") ||
src.pathname.endsWith("/stream.m3u8");
return { return {
src: stream.url, src: stream.url,

View File

@@ -71,9 +71,14 @@ export const SettingsSecurityPanel: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const Toast = useToast(); const Toast = useToast();
const { general, apiKey, loading, error, saveGeneral } = React.useContext( const {
SettingStateContext general,
); apiKey,
loading,
error,
saveGeneral,
refetch,
} = React.useContext(SettingStateContext);
const [generateAPIKey] = useGenerateAPIKey(); const [generateAPIKey] = useGenerateAPIKey();
@@ -84,6 +89,7 @@ export const SettingsSecurityPanel: React.FC = () => {
input: {}, input: {},
}, },
}); });
refetch();
} catch (e) { } catch (e) {
Toast.error(e); Toast.error(e);
} }
@@ -98,6 +104,7 @@ export const SettingsSecurityPanel: React.FC = () => {
}, },
}, },
}); });
refetch();
} catch (e) { } catch (e) {
Toast.error(e); Toast.error(e);
} }

View File

@@ -46,6 +46,8 @@ export interface ISettingsContextState {
saveScraping: (input: Partial<GQL.ConfigScrapingInput>) => void; saveScraping: (input: Partial<GQL.ConfigScrapingInput>) => void;
saveDLNA: (input: Partial<GQL.ConfigDlnaInput>) => void; saveDLNA: (input: Partial<GQL.ConfigDlnaInput>) => void;
saveUI: (input: Partial<IUIConfig>) => void; saveUI: (input: Partial<IUIConfig>) => void;
refetch: () => void;
} }
export const SettingStateContext = React.createContext<ISettingsContextState>({ export const SettingStateContext = React.createContext<ISettingsContextState>({
@@ -64,12 +66,13 @@ export const SettingStateContext = React.createContext<ISettingsContextState>({
saveScraping: () => {}, saveScraping: () => {},
saveDLNA: () => {}, saveDLNA: () => {},
saveUI: () => {}, saveUI: () => {},
refetch: () => {},
}); });
export const SettingsContext: React.FC = ({ children }) => { export const SettingsContext: React.FC = ({ children }) => {
const Toast = useToast(); const Toast = useToast();
const { data, error, loading } = useConfiguration(); const { data, error, loading, refetch } = useConfiguration();
const initialRef = useRef(false); const initialRef = useRef(false);
const [general, setGeneral] = useState<GQL.ConfigGeneralInput>({}); const [general, setGeneral] = useState<GQL.ConfigGeneralInput>({});
@@ -125,9 +128,14 @@ export const SettingsContext: React.FC = ({ children }) => {
}, [saveError, Toast]); }, [saveError, Toast]);
useEffect(() => { useEffect(() => {
if (!data?.configuration || error) return;
// always set api key
setApiKey(data.configuration.general.apiKey);
// only initialise once - assume we have control over these settings and // only initialise once - assume we have control over these settings and
// they aren't modified elsewhere // they aren't modified elsewhere
if (!data?.configuration || error || initialRef.current) return; if (initialRef.current) return;
initialRef.current = true; initialRef.current = true;
setGeneral({ ...withoutTypename(data.configuration.general) }); setGeneral({ ...withoutTypename(data.configuration.general) });
@@ -136,7 +144,6 @@ export const SettingsContext: React.FC = ({ children }) => {
setScraping({ ...withoutTypename(data.configuration.scraping) }); setScraping({ ...withoutTypename(data.configuration.scraping) });
setDLNA({ ...withoutTypename(data.configuration.dlna) }); setDLNA({ ...withoutTypename(data.configuration.dlna) });
setUI(data.configuration.ui); setUI(data.configuration.ui);
setApiKey(data.configuration.general.apiKey);
}, [data, error]); }, [data, error]);
const resetSuccess = useMemo( const resetSuccess = useMemo(
@@ -509,6 +516,7 @@ export const SettingsContext: React.FC = ({ children }) => {
saveScraping, saveScraping,
saveDLNA, saveDLNA,
saveUI, saveUI,
refetch,
}} }}
> >
{maybeRenderLoadingIndicator()} {maybeRenderLoadingIndicator()}