Remove delay, and implement custom moving function that updates the list in one event, rather than two with the previous approach.

This commit is contained in:
KotlinGeekDev
2025-11-28 16:14:47 +01:00
parent bf6109d18b
commit 80947207ab
3 changed files with 48 additions and 4 deletions
@@ -144,6 +144,31 @@ class LabeledBookmarkListEvent(
)
}
suspend fun moveBookmark(
earlierVersion: LabeledBookmarkListEvent,
bookmarkIdTag: BookmarkIdTag,
isCurrentlyPrivate: Boolean,
signer: NostrSigner,
createdAt: Long = TimeUtils.now(),
): LabeledBookmarkListEvent =
if (isCurrentlyPrivate) {
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
resign(
privateTags = privateTags.remove(bookmarkIdTag.toTagArray()),
tags = earlierVersion.tags.plus(bookmarkIdTag.toTagArray()),
signer = signer,
createdAt = createdAt,
)
} else {
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
resign(
privateTags = privateTags.plus(bookmarkIdTag.toTagArray()),
tags = earlierVersion.tags.remove(bookmarkIdTag.toTagArray()),
signer = signer,
createdAt = createdAt,
)
}
suspend fun removeBookmark(
earlierVersion: LabeledBookmarkListEvent,
bookmarkIdTag: BookmarkIdTag,