mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-21 14:26:35 +01:00
feat: recently added notifications
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { SettingsIndex } from "@/components/settings/SettingsIndex";
|
||||
import { HomeIndex } from "@/components/settings/HomeIndex";
|
||||
|
||||
export default function page() {
|
||||
return <SettingsIndex />;
|
||||
return <HomeIndex />;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,21 @@ import i18n from "@/i18n";
|
||||
import { DownloadProvider } from "@/providers/DownloadProvider";
|
||||
import {
|
||||
getOrSetDeviceId,
|
||||
getServerUrlFromStorage,
|
||||
getTokenFromStorage,
|
||||
getUserFromStorage,
|
||||
JellyfinProvider,
|
||||
} from "@/providers/JellyfinProvider";
|
||||
import { JobQueueProvider } from "@/providers/JobQueueProvider";
|
||||
import { PlaySettingsProvider } from "@/providers/PlaySettingsProvider";
|
||||
import { WebSocketProvider } from "@/providers/WebSocketProvider";
|
||||
import { Settings, useSettings } from "@/utils/atoms/settings";
|
||||
import { BACKGROUND_FETCH_TASK } from "@/utils/background-tasks";
|
||||
import {
|
||||
BACKGROUND_FETCH_TASK,
|
||||
BACKGROUND_FETCH_TASK_RECENTLY_ADDED,
|
||||
registerBackgroundFetchAsyncRecentlyAdded,
|
||||
unregisterBackgroundFetchAsyncRecentlyAdded,
|
||||
} from "@/utils/background-tasks";
|
||||
import { LogProvider, writeToLog } from "@/utils/log";
|
||||
import { storage } from "@/utils/mmkv";
|
||||
import { cancelJobById, getAllJobsByDeviceId } from "@/utils/optimize-server";
|
||||
@@ -41,6 +48,8 @@ import { SystemBars } from "react-native-edge-to-edge";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
import "react-native-reanimated";
|
||||
import { Toaster } from "sonner-native";
|
||||
import { Jellyfin } from "@jellyfin/sdk";
|
||||
import { fetchAndStoreRecentlyAdded } from "@/utils/recently-added-notifications";
|
||||
|
||||
if (!Platform.isTV) {
|
||||
Notifications.setNotificationHandler({
|
||||
@@ -97,6 +106,23 @@ function useNotificationObserver() {
|
||||
}
|
||||
|
||||
if (!Platform.isTV) {
|
||||
TaskManager.defineTask(BACKGROUND_FETCH_TASK_RECENTLY_ADDED, async () => {
|
||||
const token = getTokenFromStorage();
|
||||
const url = getServerUrlFromStorage();
|
||||
const user = getUserFromStorage();
|
||||
|
||||
console.log(
|
||||
"TaskManager ~ trigger ~ recently added notifications:",
|
||||
token,
|
||||
url,
|
||||
user?.Id
|
||||
);
|
||||
|
||||
if (!token || !url || !user?.Id) return;
|
||||
|
||||
fetchAndStoreRecentlyAdded(user.Id, url, token);
|
||||
});
|
||||
|
||||
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
|
||||
console.log("TaskManager ~ trigger");
|
||||
|
||||
@@ -278,6 +304,12 @@ function Layout() {
|
||||
ScreenOrientation.OrientationLock.PORTRAIT_UP
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.recentlyAddedNotifications === true) {
|
||||
registerBackgroundFetchAsyncRecentlyAdded();
|
||||
} else {
|
||||
unregisterBackgroundFetchAsyncRecentlyAdded();
|
||||
}
|
||||
}, [settings]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user