Skip to content

Commit 741e372

Browse files
committed
Fix compilation errors in AutomationService and BatchOperationsScreen
- AutomationService: use empty string for message instead of nonexistent report.status - BatchOperationsScreen: fix DAO method call (getAllLive → getAllAsFlow), add Profile conversion - Fix data type: selectedIds from String to Long (matches Profile.id) - Add rememberCoroutineScope() for async DB operations - Wrap all DB mutations in scope.launch for proper suspension
1 parent 618386c commit 741e372

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

app/src/main/java/com/opentasker/core/engine/AutomationService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AutomationService : Service() {
111111
taskName = task.name,
112112
durationMs = report.durationMs,
113113
success = report.success,
114-
message = report.status
114+
message = ""
115115
)
116116
db.runLogDao().insert(logEntry.toEntity())
117117

app/src/main/java/com/opentasker/ui/screens/BatchOperationsScreen.kt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import androidx.compose.ui.text.style.TextOverflow
1515
import androidx.compose.ui.unit.dp
1616
import com.opentasker.core.model.Profile
1717
import com.opentasker.core.storage.AppDatabase
18+
import com.opentasker.core.storage.toEntity
19+
import kotlinx.coroutines.launch
1820

1921
/**
2022
* Screen for batch operations on profiles: multi-select, enable/disable/delete all.
@@ -25,10 +27,12 @@ fun BatchOperationsScreen(
2527
db: AppDatabase,
2628
onBack: () -> Unit
2729
) {
28-
val allProfiles by db.profileDao().getAllLive().collectAsState(emptyList())
30+
val allProfileEntities by db.profileDao().getAllAsFlow().collectAsState(emptyList())
31+
val allProfiles = allProfileEntities.map { it.toDomain() }
2932

3033
var searchQuery by remember { mutableStateOf("") }
31-
var selectedIds by remember { mutableStateOf(setOf<String>()) }
34+
var selectedIds by remember { mutableStateOf(setOf<Long>()) }
35+
val scope = rememberCoroutineScope()
3236

3337
val filtered = allProfiles.filter { profile ->
3438
searchQuery.isEmpty() || profile.name.contains(searchQuery, ignoreCase = true)
@@ -83,11 +87,13 @@ fun BatchOperationsScreen(
8387
) {
8488
Button(onClick = {
8589
// Enable all selected
86-
selectedIds.forEach { id ->
87-
val profile = allProfiles.find { it.id == id } ?: return@forEach
88-
db.profileDao().insertOrUpdate(profile.copy(enabled = true))
90+
scope.launch {
91+
selectedIds.forEach { id ->
92+
val profile = allProfiles.find { it.id == id } ?: return@forEach
93+
db.profileDao().insertOrUpdate(profile.copy(enabled = true).toEntity())
94+
}
95+
selectedIds = emptySet()
8996
}
90-
selectedIds = emptySet()
9197
}, modifier = Modifier.weight(1f)) {
9298
Icon(Icons.Default.Done, contentDescription = null)
9399
Spacer(modifier = Modifier.width(4.dp))
@@ -98,11 +104,13 @@ fun BatchOperationsScreen(
98104

99105
Button(onClick = {
100106
// Disable all selected
101-
selectedIds.forEach { id ->
102-
val profile = allProfiles.find { it.id == id } ?: return@forEach
103-
db.profileDao().insertOrUpdate(profile.copy(enabled = false))
107+
scope.launch {
108+
selectedIds.forEach { id ->
109+
val profile = allProfiles.find { it.id == id } ?: return@forEach
110+
db.profileDao().insertOrUpdate(profile.copy(enabled = false).toEntity())
111+
}
112+
selectedIds = emptySet()
104113
}
105-
selectedIds = emptySet()
106114
}, modifier = Modifier.weight(1f)) {
107115
Icon(Icons.Default.Block, contentDescription = null)
108116
Spacer(modifier = Modifier.width(4.dp))
@@ -156,11 +164,13 @@ fun BatchOperationsScreen(
156164
confirmButton = {
157165
Button(
158166
onClick = {
159-
selectedIds.forEach { id ->
160-
db.profileDao().delete(allProfiles.find { it.id == id } ?: return@forEach)
167+
scope.launch {
168+
selectedIds.forEach { id ->
169+
db.profileDao().delete(allProfiles.find { it.id == id }?.toEntity() ?: return@forEach)
170+
}
171+
selectedIds = emptySet()
172+
showDeleteDialog = false
161173
}
162-
selectedIds = emptySet()
163-
showDeleteDialog = false
164174
},
165175
colors = ButtonDefaults.buttonColors(
166176
containerColor = MaterialTheme.colorScheme.error

0 commit comments

Comments
 (0)