Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/pages/manage/tasks/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ export interface TaskLocalSetter {

export type TaskAttribute = TaskInfo & TaskViewAttribute & TaskLocalContainer

const undoneStatePriority: Record<number, number> = {
1: 0,
0: 1,
8: 1,
9: 1,
3: 2,
5: 2,
6: 2,
}

export const Tasks = (props: TasksProps) => {
const t = useT()
const [loading, get] = useFetch(
Expand Down Expand Up @@ -85,8 +95,17 @@ export const Tasks = (props: TasksProps) => {
: -1,
}
const curSorter = createMemo(() => {
return (a: TaskInfo, b: TaskInfo) =>
(orderReverse() ? -1 : 1) * sorter[orderBy()](a, b)
return (a: TaskInfo, b: TaskInfo) => {
if (props.done === "undone" && orderBy() === "name" && !orderReverse()) {
const priorityDelta =
(undoneStatePriority[a.state] ?? 3) -
(undoneStatePriority[b.state] ?? 3)
if (priorityDelta !== 0) {
return priorityDelta
}
}
return (orderReverse() ? -1 : 1) * sorter[orderBy()](a, b)
}
})
const refresh = async () => {
const resp = await get()
Expand Down