Skip to content

Commit f482637

Browse files
committed
Merge remote-tracking branch 'origin/feat/default-dialogs' into feat/default-dialogs
# Conflicts: # surf-api-bukkit/surf-api-bukkit-plugin-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/command/dialog/subcommands/PaginatedDialogTest.kt
2 parents 2a090d0 + 5fd8b42 commit f482637

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

surf-api-bukkit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/dialog/pagination/PaginatedDialog.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ suspend fun <T> paginatedDialog(
2121
player: Player,
2222
query: DialogQuery<PageState, T>,
2323
titleBuilder: SurfComponentBuilder.(PageState, PageResult<T>) -> Unit = { _, result ->
24-
text("Seite ${result.page} von ${result.totalPages}")
24+
if (result.totalPages == 0) {
25+
text("Keine Ergebnisse")
26+
} else {
27+
text("Seite ${result.page} von ${result.totalPages}")
28+
}
2529
},
2630
searchable: Boolean = false,
2731
itemBuilder: (T) -> Pair<Component, Dialog>,
@@ -128,7 +132,7 @@ suspend fun <T> paginatedDialog(
128132
}
129133

130134
action {
131-
customPlayerClick { response, player ->
135+
customPlayerClick { response, _ ->
132136
val search = response.getText("search") ?: ""
133137

134138
scope.launch {

surf-api-bukkit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/dialog/query/states.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ data class PageState(
66
val page: Int = 1,
77
val limit: Int = 10,
88
val search: String? = null
9-
) : DialogState
9+
) : DialogState {
1010

11+
init {
12+
require(page >= 1) { "page must be >= 1, but was $page" }
13+
require(limit > 0) { "limit must be > 0, but was $limit" }
14+
}
15+
}
1116
data class CursorState(
1217
val cursor: String? = null,
1318
val history: List<String?> = emptyList(),

0 commit comments

Comments
 (0)