Added support for comment deletion.

This commit is contained in:
Koen 2023-11-29 13:54:26 +01:00
commit c806ff2e33
2 changed files with 48 additions and 44 deletions

View file

@ -154,9 +154,10 @@ class CommentsFragment : MainFragment() {
}
private fun onDelete(comment: IPlatformComment) {
val processHandle = StatePolycentric.instance.processHandle ?: return
UIDialogs.showConfirmationDialog(context, "Are you sure you want to delete this comment?", {
val processHandle = StatePolycentric.instance.processHandle ?: return@showConfirmationDialog
if (comment !is PolycentricPlatformComment) {
return
return@showConfirmationDialog
}
val index = _comments.indexOf(comment)
@ -169,7 +170,7 @@ class CommentsFragment : MainFragment() {
processHandle.delete(comment.eventPointer.process, comment.eventPointer.logicalClock)
} catch (e: Throwable) {
Logger.e(TAG, "Failed to delete event.", e);
return@launch;
return@launch
}
try {
@ -181,6 +182,7 @@ class CommentsFragment : MainFragment() {
}
}
}
})
}
fun onBackPressed(): Boolean {

View file

@ -111,9 +111,10 @@ class CommentsList : ConstraintLayout {
}
private fun onDelete(comment: IPlatformComment) {
val processHandle = StatePolycentric.instance.processHandle ?: return
UIDialogs.showConfirmationDialog(context, "Are you sure you want to delete this comment?", {
val processHandle = StatePolycentric.instance.processHandle ?: return@showConfirmationDialog
if (comment !is PolycentricPlatformComment) {
return
return@showConfirmationDialog
}
val index = _comments.indexOf(comment)
@ -138,6 +139,7 @@ class CommentsList : ConstraintLayout {
}
}
}
})
}
private fun onScrolled() {