Use Sequence instead of Collection
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Feb 2019 08:49:56 +0000 (09:49 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Feb 2019 08:49:56 +0000 (09:49 +0100)
src/main/kotlin/net/pterodactylus/sone/utils/Pagination.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt

index 772d9c4..5d48d61 100644 (file)
@@ -44,3 +44,4 @@ class Pagination<out T>(private val originalItems: List<T>, pageSize: Int): Iter
 }
 
 fun <T> Iterable<T>.paginate(pageSize: Int) = Pagination(toList(), pageSize)
+fun <T> Sequence<T>.paginate(pageSize: Int) = Pagination(toList(), pageSize)
index 05bad4a..92a856a 100644 (file)
@@ -17,7 +17,7 @@ class KnownSonesPage @Inject constructor(template: Template, webInterface: WebIn
 
        override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
                getCurrentSone(freenetRequest.toadletContext).let { currentSone ->
-                       webInterface.core.sones
+                       webInterface.core.sones.asSequence()
                                        .filterNot { freenetRequest.parameters["filter"] == "followed" && currentSone != null && !currentSone.hasFriend(it.id) }
                                        .filterNot { freenetRequest.parameters["filter"] == "not-followed" && currentSone != null && currentSone.hasFriend(it.id) }
                                        .filterNot { freenetRequest.parameters["filter"] == "new" && it.isKnown }