mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate scheduled tasks to React (#6506)
* Migrate scheduled tasks to React * Adjust margins * Use localeCompare * Clean up imports * Use legacy apiclient from useApi * Fix import * Fix nested typography * Add polling fallback * Cleanup code * Rename to tasks * Rename to Component * Use constants for websocket events * Use memo to fix timestamp rerender on run
This commit is contained in:
parent
201a3c32f8
commit
f573221643
14 changed files with 362 additions and 224 deletions
27
src/apps/dashboard/features/scheduledtasks/utils/tasks.ts
Normal file
27
src/apps/dashboard/features/scheduledtasks/utils/tasks.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import type { TaskInfo } from '@jellyfin/sdk/lib/generated-client/models/task-info';
|
||||
|
||||
export function getCategories(tasks: TaskInfo[] | undefined) {
|
||||
if (!tasks) return [];
|
||||
|
||||
const categories: string[] = [];
|
||||
|
||||
for (const task of tasks) {
|
||||
if (task.Category && !categories.includes(task.Category)) {
|
||||
categories.push(task.Category);
|
||||
}
|
||||
}
|
||||
|
||||
return categories.sort((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function getTasksByCategory(tasks: TaskInfo[] | undefined, category: string) {
|
||||
if (!tasks) return [];
|
||||
|
||||
return tasks.filter(task => task.Category == category).sort((a, b) => {
|
||||
if (a.Name && b.Name) {
|
||||
return a.Name?.localeCompare(b.Name);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue