mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-25 15:08:12 +08:00
QueueMemento : fix synchronized
This commit is contained in:
parent
629488bbe6
commit
b1f492de58
@ -49,9 +49,11 @@ internal class QueueMemento @Inject constructor(context: Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun unTrack(task: QueuedTask) {
|
fun unTrack(task: QueuedTask) {
|
||||||
|
synchronized(managedTaskInfos) {
|
||||||
managedTaskInfos.remove(task)
|
managedTaskInfos.remove(task)
|
||||||
persist()
|
persist()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun persist() {
|
private fun persist() {
|
||||||
managedTaskInfos.mapIndexedNotNull { index, queuedTask ->
|
managedTaskInfos.mapIndexedNotNull { index, queuedTask ->
|
||||||
@ -64,7 +66,6 @@ internal class QueueMemento @Inject constructor(context: Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun toTaskInfo(task: QueuedTask, order: Int): TaskInfo? {
|
private fun toTaskInfo(task: QueuedTask, order: Int): TaskInfo? {
|
||||||
synchronized(managedTaskInfos) {
|
|
||||||
return when (task) {
|
return when (task) {
|
||||||
is SendEventQueuedTask -> SendEventTaskInfo(
|
is SendEventQueuedTask -> SendEventTaskInfo(
|
||||||
localEchoId = task.event.eventId ?: "",
|
localEchoId = task.event.eventId ?: "",
|
||||||
@ -78,7 +79,6 @@ internal class QueueMemento @Inject constructor(context: Context,
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun restoreTasks(eventProcessor: EventSenderProcessor) {
|
suspend fun restoreTasks(eventProcessor: EventSenderProcessor) {
|
||||||
// events should be restarted in correct order
|
// events should be restarted in correct order
|
||||||
|
Loading…
Reference in New Issue
Block a user