mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
fix: tv playback (#820)
Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com> Signed-off-by: lancechant <13349722+lancechant@users.noreply.github.com> Co-authored-by: Fredrik Burmester <fredrik.burmester@gmail.com> Co-authored-by: Uruk <contact@uruk.dev> Co-authored-by: Gauvain <68083474+Gauvino@users.noreply.github.com>
This commit is contained in:
@@ -237,25 +237,38 @@ const loadSettings = (): Partial<Settings> => {
|
||||
return loadedValues;
|
||||
} catch (error) {
|
||||
console.error("Failed to load settings:", error);
|
||||
return defaultValues;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const EXCLUDE_FROM_SAVE = ["home"];
|
||||
|
||||
const saveSettings = (settings: Settings) => {
|
||||
for (const key of Object.keys(settings)) {
|
||||
if (EXCLUDE_FROM_SAVE.includes(key)) {
|
||||
delete settings[key as keyof Settings];
|
||||
try {
|
||||
for (const key of Object.keys(settings)) {
|
||||
if (EXCLUDE_FROM_SAVE.includes(key)) {
|
||||
delete settings[key as keyof Settings];
|
||||
}
|
||||
}
|
||||
const jsonValue = JSON.stringify(settings);
|
||||
storage.set("settings", jsonValue);
|
||||
} catch (error) {
|
||||
console.error("Failed to save settings:", error);
|
||||
}
|
||||
const jsonValue = JSON.stringify(settings);
|
||||
storage.set("settings", jsonValue);
|
||||
};
|
||||
|
||||
export const settingsAtom = atom<Partial<Settings> | null>(null);
|
||||
export const pluginSettingsAtom = atom(
|
||||
storage.get<PluginLockableSettings>(STREAMYFIN_PLUGIN_SETTINGS),
|
||||
const loadPluginSettings = () => {
|
||||
try {
|
||||
return storage.get<PluginLockableSettings>(STREAMYFIN_PLUGIN_SETTINGS);
|
||||
} catch (error) {
|
||||
console.error("Failed to load plugin settings:", error);
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const pluginSettingsAtom = atom<PluginLockableSettings | undefined>(
|
||||
loadPluginSettings(),
|
||||
);
|
||||
|
||||
export const useSettings = () => {
|
||||
@@ -317,7 +330,7 @@ export const useSettings = () => {
|
||||
// If admin sets locked to false but provides a value,
|
||||
// use user settings first and fallback on admin setting if required.
|
||||
const settings: Settings = useMemo(() => {
|
||||
const unlockedPluginDefaults = {} as Settings;
|
||||
const unlockedPluginDefaults: Partial<Settings> = {};
|
||||
const overrideSettings = Object.entries(pluginSettings ?? {}).reduce<
|
||||
Partial<Settings>
|
||||
>((acc, [key, setting]) => {
|
||||
@@ -331,14 +344,12 @@ export const useSettings = () => {
|
||||
value !== undefined &&
|
||||
_settings?.[settingsKey] !== value
|
||||
) {
|
||||
Object.assign(unlockedPluginDefaults, {
|
||||
[settingsKey]: value,
|
||||
});
|
||||
(unlockedPluginDefaults as any)[settingsKey] = value;
|
||||
}
|
||||
|
||||
Object.assign(acc, {
|
||||
[settingsKey]: locked ? value : (_settings?.[settingsKey] ?? value),
|
||||
});
|
||||
(acc as any)[settingsKey] = locked
|
||||
? value
|
||||
: (_settings?.[settingsKey] ?? value);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
@@ -23,7 +23,6 @@ export const reportPlaybackProgress = async ({
|
||||
itemId,
|
||||
positionTicks,
|
||||
IsPaused = false,
|
||||
deviceProfile,
|
||||
}: ReportPlaybackProgressParams): Promise<void> => {
|
||||
if (!api || !sessionId || !itemId || !positionTicks) {
|
||||
return;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { MMKV } from "react-native-mmkv";
|
||||
|
||||
// Create a single MMKV instance following the official documentation
|
||||
// https://github.com/mrousavy/react-native-mmkv
|
||||
export const storage = new MMKV();
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
MediaSourceInfo,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import axios from "axios";
|
||||
import { MMKV } from "react-native-mmkv";
|
||||
import { storage } from "@/utils/mmkv";
|
||||
import { writeToLog } from "./log";
|
||||
|
||||
interface IJobInput {
|
||||
@@ -173,8 +173,6 @@ export function saveDownloadItemInfoToDiskTmp(
|
||||
url: string,
|
||||
): boolean {
|
||||
try {
|
||||
const storage = new MMKV();
|
||||
|
||||
const downloadInfo = JSON.stringify({
|
||||
item,
|
||||
mediaSource,
|
||||
@@ -206,7 +204,6 @@ export function getDownloadItemInfoFromDiskTmp(itemId: string): {
|
||||
url: string;
|
||||
} | null {
|
||||
try {
|
||||
const storage = new MMKV();
|
||||
const rawInfo = storage.getString(`tmp_download_info_${itemId}`);
|
||||
|
||||
if (rawInfo) {
|
||||
@@ -227,7 +224,6 @@ export function getDownloadItemInfoFromDiskTmp(itemId: string): {
|
||||
*/
|
||||
export function deleteDownloadItemInfoFromDiskTmp(itemId: string): boolean {
|
||||
try {
|
||||
const storage = new MMKV();
|
||||
storage.delete(`tmp_download_info_${itemId}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user