mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Added support for comment deletion.
This commit is contained in:
parent
1db4d427fc
commit
c806ff2e33
2 changed files with 48 additions and 44 deletions
|
@ -154,33 +154,35 @@ class CommentsFragment : MainFragment() {
|
|||
}
|
||||
|
||||
private fun onDelete(comment: IPlatformComment) {
|
||||
val processHandle = StatePolycentric.instance.processHandle ?: return
|
||||
if (comment !is PolycentricPlatformComment) {
|
||||
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@showConfirmationDialog
|
||||
}
|
||||
|
||||
val index = _comments.indexOf(comment)
|
||||
if (index != -1) {
|
||||
_comments.removeAt(index)
|
||||
_adapterComments.notifyItemRemoved(_adapterComments.childToParentPosition(index))
|
||||
val index = _comments.indexOf(comment)
|
||||
if (index != -1) {
|
||||
_comments.removeAt(index)
|
||||
_adapterComments.notifyItemRemoved(_adapterComments.childToParentPosition(index))
|
||||
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.delete(comment.eventPointer.process, comment.eventPointer.logicalClock)
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to delete event.", e);
|
||||
return@launch;
|
||||
}
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.delete(comment.eventPointer.process, comment.eventPointer.logicalClock)
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to delete event.", e);
|
||||
return@launch
|
||||
}
|
||||
|
||||
try {
|
||||
Logger.i(TAG, "Started backfill");
|
||||
processHandle.fullyBackfillServersAnnounceExceptions();
|
||||
Logger.i(TAG, "Finished backfill");
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to fully backfill servers.", e);
|
||||
try {
|
||||
Logger.i(TAG, "Started backfill");
|
||||
processHandle.fullyBackfillServersAnnounceExceptions();
|
||||
Logger.i(TAG, "Finished backfill");
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to fully backfill servers.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun onBackPressed(): Boolean {
|
||||
|
|
|
@ -111,33 +111,35 @@ class CommentsList : ConstraintLayout {
|
|||
}
|
||||
|
||||
private fun onDelete(comment: IPlatformComment) {
|
||||
val processHandle = StatePolycentric.instance.processHandle ?: return
|
||||
if (comment !is PolycentricPlatformComment) {
|
||||
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@showConfirmationDialog
|
||||
}
|
||||
|
||||
val index = _comments.indexOf(comment)
|
||||
if (index != -1) {
|
||||
_comments.removeAt(index)
|
||||
_adapterComments.notifyItemRemoved(_adapterComments.childToParentPosition(index))
|
||||
val index = _comments.indexOf(comment)
|
||||
if (index != -1) {
|
||||
_comments.removeAt(index)
|
||||
_adapterComments.notifyItemRemoved(_adapterComments.childToParentPosition(index))
|
||||
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.delete(comment.eventPointer.process, comment.eventPointer.logicalClock)
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to delete event.", e);
|
||||
return@launch;
|
||||
}
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.delete(comment.eventPointer.process, comment.eventPointer.logicalClock)
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to delete event.", e);
|
||||
return@launch;
|
||||
}
|
||||
|
||||
try {
|
||||
Logger.i(TAG, "Started backfill");
|
||||
processHandle.fullyBackfillServersAnnounceExceptions();
|
||||
Logger.i(TAG, "Finished backfill");
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to fully backfill servers.", e);
|
||||
try {
|
||||
Logger.i(TAG, "Started backfill");
|
||||
processHandle.fullyBackfillServersAnnounceExceptions();
|
||||
Logger.i(TAG, "Finished backfill");
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to fully backfill servers.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun onScrolled() {
|
||||
|
|
Loading…
Add table
Reference in a new issue