Add support for setting a list's "exclusivity" option (#3932)

Fixes #3831
This commit is contained in:
Nik Clayton 2023-08-06 20:29:34 +02:00 committed by GitHub
commit 846289b8cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 101 additions and 109 deletions

View file

@ -38,7 +38,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi)
}
enum class Event {
CREATE_ERROR, DELETE_ERROR, RENAME_ERROR
CREATE_ERROR, DELETE_ERROR, UPDATE_ERROR
}
data class State(val lists: List<MastoList>, val loadingState: LoadingState)
@ -84,9 +84,9 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi)
}
}
fun createNewList(listName: String) {
fun createNewList(listName: String, exclusive: Boolean) {
viewModelScope.launch {
api.createList(listName).fold(
api.createList(listName, exclusive).fold(
{ list ->
updateState {
copy(lists = lists + list)
@ -99,16 +99,16 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi)
}
}
fun renameList(listId: String, listName: String) {
fun updateList(listId: String, listName: String, exclusive: Boolean) {
viewModelScope.launch {
api.updateList(listId, listName).fold(
api.updateList(listId, listName, exclusive).fold(
{ list ->
updateState {
copy(lists = lists.replacedFirstWhich(list) { it.id == listId })
}
},
{
sendEvent(Event.RENAME_ERROR)
sendEvent(Event.UPDATE_ERROR)
}
)
}