Use background coroutines for modification operations. Use FollowSet in callbacks, rather than just the set identifier.
This commit is contained in:
+6
-6
@@ -154,9 +154,9 @@ fun ListsScreen(
|
||||
account = accountViewModel.account,
|
||||
)
|
||||
},
|
||||
deleteItem = { identifier ->
|
||||
deleteItem = { followSet ->
|
||||
followSetsViewModel.deleteFollowSet(
|
||||
listIdentifier = identifier,
|
||||
followSet = followSet,
|
||||
account = accountViewModel.account,
|
||||
)
|
||||
},
|
||||
@@ -178,7 +178,7 @@ fun ListsScreen(
|
||||
onProfileRemove = {
|
||||
followSetsViewModel.removeUserFromSet(
|
||||
it,
|
||||
leFollowSet.identifierTag,
|
||||
leFollowSet,
|
||||
accountViewModel.account,
|
||||
)
|
||||
},
|
||||
@@ -191,7 +191,7 @@ fun ListsScreen(
|
||||
onListDelete = {
|
||||
isFollowSetSelected.value = false
|
||||
followSetsViewModel.deleteFollowSet(
|
||||
leFollowSet.identifierTag,
|
||||
leFollowSet,
|
||||
accountViewModel.account,
|
||||
)
|
||||
},
|
||||
@@ -205,8 +205,8 @@ fun CustomListsScreen(
|
||||
refresh: () -> Unit,
|
||||
addItem: (title: String, description: String?, listType: ListVisibility) -> Unit,
|
||||
openItem: (identifier: String) -> Unit,
|
||||
renameItem: (targetSet: FollowSet, newName: String) -> Unit,
|
||||
deleteItem: (setIdentifier: String) -> Unit,
|
||||
renameItem: (followSet: FollowSet, newName: String) -> Unit,
|
||||
deleteItem: (followSet: FollowSet) -> Unit,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
) {
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ fun FollowSetFeedView(
|
||||
onRefresh: () -> Unit = {},
|
||||
onOpenItem: (String) -> Unit = {},
|
||||
onRenameItem: (targetSet: FollowSet, newName: String) -> Unit,
|
||||
onDeleteItem: (setIdentifier: String) -> Unit,
|
||||
onDeleteItem: (followSet: FollowSet) -> Unit,
|
||||
) {
|
||||
when (followSetState) {
|
||||
FollowSetState.Loading -> LoadingFeed()
|
||||
@@ -90,7 +90,7 @@ fun FollowListLoaded(
|
||||
onRefresh: () -> Unit = {},
|
||||
onItemClick: (itemIdentifier: String) -> Unit = {},
|
||||
onItemRename: (followSet: FollowSet, newName: String) -> Unit,
|
||||
onItemDelete: (itemIdentifier: String) -> Unit,
|
||||
onItemDelete: (followSet: FollowSet) -> Unit,
|
||||
) {
|
||||
Log.d("FollowSetComposable", "FollowListLoaded: Follow Set size: ${loadedFeedState.size}")
|
||||
|
||||
@@ -113,7 +113,7 @@ fun FollowListLoaded(
|
||||
onItemRename(set, it)
|
||||
},
|
||||
onFollowSetDelete = {
|
||||
onItemDelete(set.identifierTag)
|
||||
onItemDelete(set)
|
||||
},
|
||||
)
|
||||
Spacer(modifier = StdVertSpacer)
|
||||
|
||||
+17
-16
@@ -124,7 +124,7 @@ class NostrListFeedViewModel(
|
||||
if (account.settings.isWriteable()) {
|
||||
println("You are in read-only mode. Please login to make modifications.")
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
PeopleListEvent.createListWithDescription(
|
||||
dTag = UUID.randomUUID().toString(),
|
||||
key = "title",
|
||||
@@ -148,7 +148,7 @@ class NostrListFeedViewModel(
|
||||
if (!account.settings.isWriteable()) {
|
||||
println("You are in read-only mode. Please login to make modifications.")
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val setEvent = getFollowSetNote(followSet.identifierTag, account)?.event as PeopleListEvent
|
||||
PeopleListEvent.modifyTag(
|
||||
earlierVersion = setEvent,
|
||||
@@ -165,15 +165,15 @@ class NostrListFeedViewModel(
|
||||
}
|
||||
|
||||
fun deleteFollowSet(
|
||||
listIdentifier: String,
|
||||
followSet: FollowSet,
|
||||
account: Account,
|
||||
) {
|
||||
if (!account.settings.isWriteable()) {
|
||||
println("You are in read-only mode. Please login to make modifications.")
|
||||
return
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
val followSetEvent = getFollowSetNote(listIdentifier, account)?.event as PeopleListEvent
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val followSetEvent = getFollowSetNote(followSet.identifierTag, account)?.event as PeopleListEvent
|
||||
account.signer.sign(
|
||||
DeletionEvent.build(listOf(followSetEvent)),
|
||||
) {
|
||||
@@ -193,7 +193,7 @@ class NostrListFeedViewModel(
|
||||
println("You are in read-only mode. Please login to make modifications.")
|
||||
return
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val followSetEvent = getFollowSetNote(followSet.identifierTag, account)?.event as PeopleListEvent
|
||||
PeopleListEvent.addUser(
|
||||
earlierVersion = followSetEvent,
|
||||
@@ -210,18 +210,19 @@ class NostrListFeedViewModel(
|
||||
|
||||
fun removeUserFromSet(
|
||||
userProfileHex: String,
|
||||
listIdentifier: String,
|
||||
followSet: FollowSet,
|
||||
account: Account,
|
||||
) {
|
||||
if (!account.settings.isWriteable()) {
|
||||
println("You are in read-only mode. Please login to make modifications.")
|
||||
return
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
val followSetEvent = getFollowSetNote(listIdentifier, account)?.event as PeopleListEvent
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val followSetEvent = getFollowSetNote(followSet.identifierTag, account)?.event as PeopleListEvent
|
||||
PeopleListEvent.removeUser(
|
||||
earlierVersion = followSetEvent,
|
||||
pubKeyHex = userProfileHex,
|
||||
isPrivate = followSet.visibility == ListVisibility.Private,
|
||||
signer = account.signer,
|
||||
) {
|
||||
Amethyst.instance.client.send(it)
|
||||
@@ -242,13 +243,13 @@ class NostrListFeedViewModel(
|
||||
private val bundler = BundledUpdate(2000, Dispatchers.IO)
|
||||
|
||||
override fun invalidateData(ignoreIfDoing: Boolean) {
|
||||
refresh()
|
||||
// bundler.invalidate(ignoreIfDoing) {
|
||||
// // adds the time to perform the refresh into this delay
|
||||
// // holding off new updates in case of heavy refresh routines.
|
||||
// sampleRefresh()
|
||||
// // refreshSuspended()
|
||||
// }
|
||||
// refresh()
|
||||
bundler.invalidate(ignoreIfDoing) {
|
||||
// adds the time to perform the refresh into this delay
|
||||
// holding off new updates in case of heavy refresh routines.
|
||||
|
||||
refreshSuspended()
|
||||
}
|
||||
}
|
||||
|
||||
var collectorJob: Job? = null
|
||||
|
||||
Reference in New Issue
Block a user