mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-09 10:31:55 +01:00
feat: Add session count to app badge (#575)
This commit is contained in:
@@ -3,6 +3,8 @@ import { apiAtom } from "@/providers/JellyfinProvider";
|
||||
import { useAtom } from "jotai";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import { userAtom } from "@/providers/JellyfinProvider";
|
||||
import { Platform } from "react-native";
|
||||
const Notifications = !Platform.isTV ? require("expo-notifications") : null;
|
||||
|
||||
export interface useSessionsProps {
|
||||
refetchInterval: number;
|
||||
@@ -22,9 +24,13 @@ export const useSessions = ({ refetchInterval = 5 * 1000, activeWithinSeconds =
|
||||
const response = await getSessionApi(api).getSessions({
|
||||
activeWithinSeconds: activeWithinSeconds,
|
||||
});
|
||||
return response.data
|
||||
|
||||
const result = response.data
|
||||
.filter((s) => s.NowPlayingItem)
|
||||
.sort((a, b) => (b.NowPlayingItem?.Name ?? "").localeCompare(a.NowPlayingItem?.Name ?? ""));
|
||||
|
||||
Notifications.setBadgeCountAsync(result.length);
|
||||
return result
|
||||
},
|
||||
refetchInterval: refetchInterval,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user