fix(syspulse): filter pending scheduled tasks, conditionally show cancel button, and parse API error messages (v1.3.4)
Build & Release Android APK / Build & Publish Release APK (push) Successful in 1m56s
Build & Release Android APK / Build & Publish Release APK (push) Successful in 1m56s
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "com.expapp.trigger"
|
||||
minSdk = 24
|
||||
targetSdk = 34
|
||||
versionCode = 22
|
||||
versionName = "1.3.3"
|
||||
versionCode = 23
|
||||
versionName = "1.3.4"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
@@ -328,7 +328,13 @@ class SysPulseClient(
|
||||
|
||||
val body = res.body?.string().orEmpty()
|
||||
if (!res.isSuccessful) {
|
||||
runOnMain { onResult(Result.failure(IOException("HTTP ${res.code}"))) }
|
||||
val errorMsg = try {
|
||||
val json = JsonParser.parseString(body).asJsonObject
|
||||
json.get("error")?.asString ?: "HTTP ${res.code}"
|
||||
} catch (_: Exception) {
|
||||
"HTTP ${res.code}"
|
||||
}
|
||||
runOnMain { onResult(Result.failure(IOException(errorMsg))) }
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -697,16 +697,22 @@ fun ScheduledTaskCard(
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = { onCancel(task) },
|
||||
modifier = Modifier.size(32.dp)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Close,
|
||||
contentDescription = "Cancel Task",
|
||||
tint = RedVibrant,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
val isCancellable = task.status.equals("pending", ignoreCase = true) ||
|
||||
task.status.equals("active", ignoreCase = true) ||
|
||||
task.status.equals("scheduled", ignoreCase = true)
|
||||
|
||||
if (isCancellable) {
|
||||
IconButton(
|
||||
onClick = { onCancel(task) },
|
||||
modifier = Modifier.size(32.dp)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Close,
|
||||
contentDescription = "Cancel Task",
|
||||
tint = RedVibrant,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +137,13 @@ fun DashboardScreen(
|
||||
}
|
||||
|
||||
sysPulseClient.fetchTasks(effectiveUrl, effectiveSecret) { result ->
|
||||
result.onSuccess {
|
||||
scheduledTasks = it
|
||||
result.onSuccess { allTasks ->
|
||||
// Only show active pending tasks in the dashboard
|
||||
scheduledTasks = allTasks.filter {
|
||||
it.status.equals("pending", ignoreCase = true) ||
|
||||
it.status.equals("active", ignoreCase = true) ||
|
||||
it.status.equals("scheduled", ignoreCase = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user