Add support for setting a list's "exclusivity" option (#3932)
Fixes #3831
This commit is contained in:
parent
6766509977
commit
846289b8cc
55 changed files with 101 additions and 109 deletions
|
|
@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue