[collab] Always push out new pages states from ListLoaders (IJPL-157270)

#IJPL-157270 Fixed

If these are not pushed out, a sequence like this will have incorrect results:
1. Refresh the list, 0 pages loaded, list = []
2. Update manually by adding an entry, list = [some_entry]
3. Perform some action on-server that removes the entity, but does not notify IDE.
4. Refresh the list, 0 pages loaded, list = [some_entry]

In the final step, the pagesFlow would not push out the freshly loaded list.
From the perspective of pages that's fine, but the final list is inconsistent and
should always be overridden by refreshes.

GitOrigin-RevId: 631041c137bde50e2fd8ede0d3f1dc2d3a83b564
This commit is contained in:
Chris Lemaire
2024-06-27 11:50:29 +02:00
committed by intellij-monorepo-bot
parent 1d6a606bea
commit a53518affe
3 changed files with 23 additions and 31 deletions

View File

@@ -36,10 +36,7 @@ private class GitLabGraphQLETagListLoader<K, V>(
shouldTryToLoadAll: Boolean = false,
private val performRequest: suspend (cursor: String?) -> GraphQLConnectionDTO<V>?
) : PaginatedPotentiallyInfiniteListLoader<PageInfo, K, V>(cs, PageInfo(), extractKey, shouldTryToLoadAll) {
/**
*
*/
) : PaginatedPotentiallyInfiniteListLoader<PageInfo, K, V>(PageInfo(), extractKey, shouldTryToLoadAll) {
data class PageInfo(
val cursor: String? = null,
val nextCursor: String? = null,

View File

@@ -3,10 +3,13 @@ package org.jetbrains.plugins.gitlab.mergerequest.data.loaders
import com.intellij.collaboration.api.HttpStatusErrorException
import com.intellij.collaboration.api.util.LinkHttpHeaderValue
import com.intellij.collaboration.async.*
import com.intellij.collaboration.async.Change
import com.intellij.collaboration.async.PaginatedPotentiallyInfiniteListLoader
import com.intellij.collaboration.async.ReloadablePotentiallyInfiniteListLoader
import com.intellij.collaboration.async.launchNow
import com.intellij.collaboration.util.URIUtil
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import org.jetbrains.plugins.gitlab.mergerequest.data.loaders.GitLabRestETagListLoader.PageInfo
import java.net.HttpURLConnection
@@ -43,14 +46,11 @@ private class GitLabRestETagListLoader<K, V>(
shouldTryToLoadAll: Boolean = false,
private val performRequest: suspend (uri: URI, eTag: String?) -> HttpResponse<out List<V>?>
) : PaginatedPotentiallyInfiniteListLoader<PageInfo, K, V>(cs, PageInfo(initialURI), extractKey, shouldTryToLoadAll) {
) : PaginatedPotentiallyInfiniteListLoader<PageInfo, K, V>(PageInfo(initialURI), extractKey, shouldTryToLoadAll) {
companion object {
private const val ETAG_HEADER = "ETag"
}
/**
*
*/
data class PageInfo(
val link: URI,
val nextLink: URI? = null,