Introduce user removal functionality.
This commit is contained in:
+18
-6
@@ -933,9 +933,15 @@ private fun ProfileActions(
|
|||||||
followLists = tempFollowLists,
|
followLists = tempFollowLists,
|
||||||
addUser = { index, list ->
|
addUser = { index, list ->
|
||||||
Log.d("Amethyst", "ProfileActions: Updating list ...")
|
Log.d("Amethyst", "ProfileActions: Updating list ...")
|
||||||
val newList = list.memberList + baseUser.pubkeyHex
|
val newList = tempFollowLists[index].memberList + baseUser.pubkeyHex
|
||||||
tempFollowLists[index] = tempFollowLists[index].copy(memberList = newList)
|
tempFollowLists[index] = tempFollowLists[index].copy(memberList = newList)
|
||||||
println("Updated List.")
|
println("Updated List. New size: ${tempFollowLists[index].memberList.size}")
|
||||||
|
},
|
||||||
|
removeUser = { index ->
|
||||||
|
Log.d("Amethyst", "ProfileActions: Updating list ...")
|
||||||
|
val newList = tempFollowLists[index].memberList - baseUser.pubkeyHex
|
||||||
|
tempFollowLists[index] = tempFollowLists[index].copy(memberList = newList)
|
||||||
|
println("Updated List. New size: ${tempFollowLists[index].memberList.size}")
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1030,7 +1036,8 @@ fun FollowSetsActionMenu(
|
|||||||
userHex: String,
|
userHex: String,
|
||||||
followLists: List<FollowInfo>,
|
followLists: List<FollowInfo>,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
addUser: (listIndex: Int, list: FollowInfo) -> Unit,
|
addUser: (followListItemIndex: Int, list: FollowInfo) -> Unit,
|
||||||
|
removeUser: (followListItemIndex: Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
val (isMenuOpen, setMenuValue) = remember { mutableStateOf(false) }
|
val (isMenuOpen, setMenuValue) = remember { mutableStateOf(false) }
|
||||||
val uiScope = rememberCoroutineScope()
|
val uiScope = rememberCoroutineScope()
|
||||||
@@ -1091,12 +1098,16 @@ fun FollowSetsActionMenu(
|
|||||||
listHeader = list.name,
|
listHeader = list.name,
|
||||||
listIsPublic = !list.isPrivate,
|
listIsPublic = !list.isPrivate,
|
||||||
isUserInList = list.memberList.contains(userHex),
|
isUserInList = list.memberList.contains(userHex),
|
||||||
) {
|
onRemoveUser = {
|
||||||
|
removeUser(index)
|
||||||
|
},
|
||||||
|
onAddUser = {
|
||||||
println("List contains user -> ${list.memberList.contains(userHex)}")
|
println("List contains user -> ${list.memberList.contains(userHex)}")
|
||||||
println("Adding user to List -> ${list.name}")
|
println("Adding user to List -> ${list.name}")
|
||||||
addUser(index, list)
|
addUser(index, list)
|
||||||
println("List contains user -> ${list.memberList.contains(userHex)}")
|
println("List contains user -> ${list.memberList.contains(userHex)}")
|
||||||
}
|
},
|
||||||
|
)
|
||||||
},
|
},
|
||||||
onClick = {},
|
onClick = {},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
@@ -1144,6 +1155,7 @@ fun FollowSetItem(
|
|||||||
listIsPublic: Boolean,
|
listIsPublic: Boolean,
|
||||||
isUserInList: Boolean,
|
isUserInList: Boolean,
|
||||||
onAddUser: () -> Unit,
|
onAddUser: () -> Unit,
|
||||||
|
onRemoveUser: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
@@ -1198,7 +1210,7 @@ fun FollowSetItem(
|
|||||||
Spacer(modifier = StdHorzSpacer)
|
Spacer(modifier = StdHorzSpacer)
|
||||||
AssistChip(
|
AssistChip(
|
||||||
onClick = {
|
onClick = {
|
||||||
onAddUser()
|
if (isUserInList) onRemoveUser() else onAddUser()
|
||||||
},
|
},
|
||||||
label = {
|
label = {
|
||||||
Text(text = if (isUserInList) "Remove" else "Add")
|
Text(text = if (isUserInList) "Remove" else "Add")
|
||||||
|
|||||||
Reference in New Issue
Block a user