This commit is contained in:
Fredrik Burmester
2024-10-01 17:42:09 +02:00
parent dd1f02a13b
commit 0acc1f03f0
12 changed files with 425 additions and 130 deletions

View File

@@ -73,7 +73,8 @@ export type Settings = {
forwardSkipTime: number;
rewindSkipTime: number;
optimizedVersionsServerUrl?: string | null;
downloadMethod?: "optimized" | "remux";
downloadMethod: "optimized" | "remux";
autoDownload: boolean;
};
/**
*
@@ -110,6 +111,7 @@ const loadSettings = async (): Promise<Settings> => {
rewindSkipTime: 10,
optimizedVersionsServerUrl: null,
downloadMethod: "remux",
autoDownload: false,
};
try {

23
utils/background-tasks.ts Normal file
View File

@@ -0,0 +1,23 @@
import * as BackgroundFetch from "expo-background-fetch";
export const BACKGROUND_FETCH_TASK = "background-fetch";
export async function registerBackgroundFetchAsync() {
try {
BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: 60 * 1, // 1 minutes
stopOnTerminate: false, // android only,
startOnBoot: false, // android only
});
} catch (error) {
console.log("Error registering background fetch task", error);
}
}
export async function unregisterBackgroundFetchAsync() {
try {
BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);
} catch (error) {
console.log("Error unregistering background fetch task", error);
}
}

View File

@@ -53,6 +53,11 @@ export async function getAllJobsByDeviceId({
},
});
if (statusResponse.status !== 200) {
console.error(
statusResponse.status,
statusResponse.data,
statusResponse.statusText
);
throw new Error("Failed to fetch job status");
}