mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-20 04:40:27 +01:00
fix: sort sessions by name
This commit is contained in:
@@ -9,14 +9,11 @@ export interface useSessionsProps {
|
|||||||
activeWithinSeconds: number;
|
activeWithinSeconds: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSessions = ({
|
export const useSessions = ({ refetchInterval = 5 * 1000, activeWithinSeconds = 360 }: useSessionsProps) => {
|
||||||
refetchInterval = 5 * 1000,
|
|
||||||
activeWithinSeconds = 360,
|
|
||||||
}: useSessionsProps) => {
|
|
||||||
const [api] = useAtom(apiAtom);
|
const [api] = useAtom(apiAtom);
|
||||||
const [user] = useAtom(userAtom);
|
const [user] = useAtom(userAtom);
|
||||||
|
|
||||||
const { data, isLoading, error } = useQuery({
|
const { data, isLoading } = useQuery({
|
||||||
queryKey: ["sessions"],
|
queryKey: ["sessions"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !user || !user.Policy?.IsAdministrator) {
|
if (!api || !user || !user.Policy?.IsAdministrator) {
|
||||||
@@ -25,11 +22,11 @@ export const useSessions = ({
|
|||||||
const response = await getSessionApi(api).getSessions({
|
const response = await getSessionApi(api).getSessions({
|
||||||
activeWithinSeconds: activeWithinSeconds,
|
activeWithinSeconds: activeWithinSeconds,
|
||||||
});
|
});
|
||||||
return response.data.filter((s) => s.NowPlayingItem);
|
return response.data
|
||||||
|
.filter((s) => s.NowPlayingItem)
|
||||||
|
.sort((a, b) => (b.NowPlayingItem?.Name ?? "").localeCompare(a.NowPlayingItem?.Name ?? ""));
|
||||||
},
|
},
|
||||||
refetchInterval: refetchInterval,
|
refetchInterval: refetchInterval,
|
||||||
//enabled: !!user || !!user.Policy?.IsAdministrator,
|
|
||||||
//cacheTime: 0
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { sessions: data, isLoading };
|
return { sessions: data, isLoading };
|
||||||
|
|||||||
Reference in New Issue
Block a user