Limit sort order for astrid manual sorting

Fix crash when sorting ~1000 tasks
pull/2068/head
Alex Baker 2 years ago
parent 03f695f625
commit d82e594043

@ -111,11 +111,11 @@ class SubtasksFilterUpdater @Inject constructor(
return idToNode[taskId]
}
private val orderedIds: Array<String>
private val orderedIds: List<String>
get() {
val ids = ArrayList<String>()
orderedIdHelper(treeRoot, ids)
return ids.toTypedArray()
return ids
}
private val orderString: String
@ -320,15 +320,17 @@ class SubtasksFilterUpdater @Inject constructor(
companion object {
const val ACTIVE_TASKS_ORDER = "active_tasks_order" // $NON-NLS-1$
const val TODAY_TASKS_ORDER = "today_tasks_order" // $NON-NLS-1$
private const val MAX_ORDERED_TASKS = 900
fun buildOrderString(ids: Array<String>): String {
fun buildOrderString(ids: List<String>): String {
val builder = StringBuilder()
if (ids.isEmpty()) {
return "(1)" // $NON-NLS-1$
}
for (i in ids.indices.reversed()) {
val indices = ids.indices.reversed().take(MAX_ORDERED_TASKS)
indices.forEach { i ->
builder.append(Task.UUID.eq(ids[i]).toString())
if (i > 0) {
if (i != indices.last()) {
builder.append(", ") // $NON-NLS-1$
}
}

@ -79,7 +79,7 @@ class SubtasksHelper @Inject constructor(
return ids
}
fun getStringIdArray(serializedTree: String?): Array<String> {
fun getStringIdArray(serializedTree: String?): List<String> {
val ids = ArrayList<String>()
val values = serializedTree!!.split("""[\[\],"\s]""".toRegex()).toTypedArray() // Split on [ ] , or whitespace chars
for (idString in values) {
@ -87,7 +87,7 @@ class SubtasksHelper @Inject constructor(
ids.add(idString)
}
}
return ids.toTypedArray()
return ids
}
/** Takes a subtasks string containing local ids and remaps it to one containing UUIDs */

Loading…
Cancel
Save