mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 15:01:57 +03:00
filter selected tasks for v1 and v2
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
98cd991502
commit
edd42aabd1
5 changed files with 25 additions and 31 deletions
|
@ -46,7 +46,7 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val result = sut?.getTaskList("assistant")
|
val result = sut?.getTaskList("assistant")
|
||||||
assertTrue(result?.tasks?.isEmpty() == true || (result?.tasks?.size ?: 0) > 0)
|
assertTrue(result?.isEmpty() == true || (result?.size ?: 0) > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,13 +81,11 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||||
|
|
||||||
sleep(120)
|
sleep(120)
|
||||||
|
|
||||||
val resultOfTaskList = sut?.getTaskList("assistant")
|
val taskList = sut?.getTaskList("assistant")
|
||||||
assertTrue(resultOfTaskList != null)
|
assertTrue(taskList != null)
|
||||||
|
|
||||||
sleep(120)
|
sleep(120)
|
||||||
|
|
||||||
val taskList = resultOfTaskList?.tasks
|
|
||||||
|
|
||||||
assert((taskList?.size ?: 0) > 0)
|
assert((taskList?.size ?: 0) > 0)
|
||||||
|
|
||||||
val result = sut?.deleteTask(taskList!!.first().id)
|
val result = sut?.deleteTask(taskList!!.first().id)
|
||||||
|
|
|
@ -102,7 +102,7 @@ class AssistantViewModel(
|
||||||
val taskType = _selectedTaskType.value?.id ?: return@launch
|
val taskType = _selectedTaskType.value?.id ?: return@launch
|
||||||
val result = repository.getTaskList(taskType)
|
val result = repository.getTaskList(taskType)
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
taskList = result.tasks.filter { it.appId == "assistant" }
|
taskList = result
|
||||||
_filteredTaskList.update {
|
_filteredTaskList.update {
|
||||||
taskList?.sortedByDescending { task ->
|
taskList?.sortedByDescending { task ->
|
||||||
task.id
|
task.id
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInputShape
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInputShape
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskList
|
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutput
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutput
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutputShape
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutputShape
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||||
|
@ -47,26 +46,24 @@ class AssistantMockRepository(private val giveEmptyTasks: Boolean = false) : Ass
|
||||||
return RemoteOperationResult<Void>(RemoteOperationResult.ResultCode.OK)
|
return RemoteOperationResult<Void>(RemoteOperationResult.ResultCode.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTaskList(taskType: String): TaskList {
|
override fun getTaskList(taskType: String): List<Task> {
|
||||||
return if (giveEmptyTasks) {
|
return if (giveEmptyTasks) {
|
||||||
TaskList(listOf())
|
listOf()
|
||||||
} else {
|
} else {
|
||||||
TaskList(
|
listOf(
|
||||||
listOf(
|
Task(
|
||||||
Task(
|
1,
|
||||||
1,
|
"FreePrompt",
|
||||||
"FreePrompt",
|
null,
|
||||||
null,
|
"12",
|
||||||
"12",
|
"",
|
||||||
"",
|
TaskInput("Give me some long text 1"),
|
||||||
TaskInput("Give me some long text 1"),
|
TaskOutput("Lorem ipsum".getRandomString(100)),
|
||||||
TaskOutput("Lorem ipsum".getRandomString(100)),
|
1707692337,
|
||||||
1707692337,
|
1707692337,
|
||||||
1707692337,
|
1707692337,
|
||||||
1707692337,
|
1707692337,
|
||||||
1707692337,
|
1707692337
|
||||||
1707692337
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import com.owncloud.android.lib.resources.assistant.v2.CreateTaskRemoteOperation
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.DeleteTaskRemoteOperationV2
|
import com.owncloud.android.lib.resources.assistant.v2.DeleteTaskRemoteOperationV2
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.GetTaskListRemoteOperationV2
|
import com.owncloud.android.lib.resources.assistant.v2.GetTaskListRemoteOperationV2
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.GetTaskTypesRemoteOperationV2
|
import com.owncloud.android.lib.resources.assistant.v2.GetTaskTypesRemoteOperationV2
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskList
|
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||||
import com.owncloud.android.lib.resources.status.OCCapability
|
import com.owncloud.android.lib.resources.status.OCCapability
|
||||||
|
@ -58,16 +58,16 @@ class AssistantRepository(private val client: NextcloudClient, capability: OCCap
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("ReturnCount")
|
@Suppress("ReturnCount")
|
||||||
override fun getTaskList(taskType: String): TaskList? {
|
override fun getTaskList(taskType: String): List<Task>? {
|
||||||
if (supportsV2) {
|
if (supportsV2) {
|
||||||
val result = GetTaskListRemoteOperationV2(taskType).execute(client)
|
val result = GetTaskListRemoteOperationV2(taskType).execute(client)
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
return result.resultData
|
return result.resultData.tasks.filter { it.appId == "assistant" }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val result = GetTaskListRemoteOperationV1("assistant").execute(client)
|
val result = GetTaskListRemoteOperationV1("assistant").execute(client)
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
return result.resultData.toV2()
|
return result.resultData.toV2().tasks.filter { it.type == taskType }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
package com.nextcloud.client.assistant.repository
|
package com.nextcloud.client.assistant.repository
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskList
|
|
||||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||||
|
|
||||||
interface AssistantRepositoryType {
|
interface AssistantRepositoryType {
|
||||||
|
@ -16,7 +15,7 @@ interface AssistantRepositoryType {
|
||||||
|
|
||||||
fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void>
|
fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void>
|
||||||
|
|
||||||
fun getTaskList(taskType: String): TaskList?
|
fun getTaskList(taskType: String): List<com.owncloud.android.lib.resources.assistant.v2.model.Task>?
|
||||||
|
|
||||||
fun deleteTask(id: Long): RemoteOperationResult<Void>
|
fun deleteTask(id: Long): RemoteOperationResult<Void>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue