queue: invalidate keyset cursors on edits

This commit is contained in:
austinried
2026-11-14 12:03:42 +00:00
parent 94c7fba536
commit 762639cab5
2 changed files with 14 additions and 0 deletions
@@ -1094,6 +1094,7 @@ class QueueRepository(
dao.insert(entries.mapIndexed { index, entry -> entry.copy(id = 0, position = index.toLong()) }) dao.insert(entries.mapIndexed { index, entry -> entry.copy(id = 0, position = index.toLong()) })
} }
} }
keyCache.clear()
queueVersion.incrementAndGet() queueVersion.incrementAndGet()
} }
@@ -1106,6 +1107,7 @@ class QueueRepository(
) )
} }
} }
keyCache.clear()
queueVersion.incrementAndGet() queueVersion.incrementAndGet()
} }
@@ -458,6 +458,18 @@ class QueueRepositoryTest {
assertEquals(3L, repository.remapPosition(updated, point.current!!)) assertEquals(3L, repository.remapPosition(updated, point.current!!))
} }
@Test
fun aRemovalDoesNotReusePreEditKeysetRows() =
runTest {
seedLibrary()
val snapshot = repository.snapshotAfter(listOf(repository.albumEntry(1, "al1")))
assertEquals("s1", repository.itemAt(snapshot, 0)?.song?.id)
repository.removeAt(snapshot, 0)
assertEquals(listOf("s2", "s3"), resolveAll(repository.snapshot()))
}
@Test @Test
fun anUnrelatedOriginResetRemapsWithinTheSecondUnchangedFragment() = fun anUnrelatedOriginResetRemapsWithinTheSecondUnchangedFragment() =
runTest { runTest {