mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-24 20:18:09 +00:00
fix: task not registered properly
This commit is contained in:
@@ -294,6 +294,32 @@ function Layout() {
|
||||
checkAndRequestPermissions();
|
||||
}, []);
|
||||
|
||||
const checkStatusAsync = async () => {
|
||||
if (Platform.isTV) return;
|
||||
|
||||
await BackgroundFetch.getStatusAsync();
|
||||
return await TaskManager.isTaskRegisteredAsync(
|
||||
BACKGROUND_FETCH_TASK_RECENTLY_ADDED
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const isRegistered = await checkStatusAsync();
|
||||
|
||||
if (settings.recentlyAddedNotifications === false && isRegistered) {
|
||||
console.log("unregisterBackgroundFetchAsyncRecentlyAdded");
|
||||
unregisterBackgroundFetchAsyncRecentlyAdded();
|
||||
} else if (
|
||||
settings.recentlyAddedNotifications === true &&
|
||||
!isRegistered
|
||||
) {
|
||||
console.log("registerBackgroundFetchAsyncRecentlyAdded");
|
||||
registerBackgroundFetchAsyncRecentlyAdded();
|
||||
}
|
||||
})();
|
||||
}, [settings.recentlyAddedNotifications]);
|
||||
|
||||
useEffect(() => {
|
||||
// If the user has auto rotate enabled, unlock the orientation
|
||||
if (settings.autoRotate === true) {
|
||||
@@ -304,12 +330,6 @@ function Layout() {
|
||||
ScreenOrientation.OrientationLock.PORTRAIT_UP
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.recentlyAddedNotifications === true) {
|
||||
registerBackgroundFetchAsyncRecentlyAdded();
|
||||
} else {
|
||||
unregisterBackgroundFetchAsyncRecentlyAdded();
|
||||
}
|
||||
}, [settings]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user