Новый конвейер задач и уведомлений
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.github.nullptroma.wallenc.domain.tasks
|
||||
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
|
||||
interface ITaskOrchestrator {
|
||||
val pipelineState: StateFlow<PipelineState>
|
||||
@@ -9,14 +10,11 @@ interface ITaskOrchestrator {
|
||||
|
||||
fun enqueue(
|
||||
title: String,
|
||||
requiresForeground: Boolean = true,
|
||||
dispatcher: CoroutineDispatcher,
|
||||
work: PipelineWork,
|
||||
): TaskId
|
||||
|
||||
fun cancel(taskId: TaskId): Boolean
|
||||
|
||||
/** Cancels the currently running task, if any. */
|
||||
fun cancelCurrent(): Boolean
|
||||
|
||||
fun cancelAll()
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ package com.github.nullptroma.wallenc.domain.tasks
|
||||
|
||||
data class PipelineState(
|
||||
val tasks: List<PipelineTask>,
|
||||
val currentTaskId: TaskId?,
|
||||
val runningTaskIds: Set<TaskId>,
|
||||
)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.github.nullptroma.wallenc.domain.tasks
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
|
||||
data class PipelineTask(
|
||||
val id: TaskId,
|
||||
val title: String,
|
||||
val requiresForeground: Boolean,
|
||||
val dispatcher: CoroutineDispatcher,
|
||||
val state: TaskRunState,
|
||||
)
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.github.nullptroma.wallenc.domain.tasks
|
||||
|
||||
data class TaskForegroundItem(
|
||||
val taskId: TaskId,
|
||||
val title: String,
|
||||
val progress: TaskProgress?,
|
||||
)
|
||||
|
||||
sealed class TaskForegroundUiState {
|
||||
data object Hidden : TaskForegroundUiState()
|
||||
data class Visible(
|
||||
val title: String,
|
||||
val progress: TaskProgress?,
|
||||
val tasks: List<TaskForegroundItem>,
|
||||
) : TaskForegroundUiState()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user