Fix open group deletion issue

This commit is contained in:
Niels Andriesse 2021-07-09 09:38:45 +10:00
parent 9fd2788664
commit ecc7f50ac4
4 changed files with 14 additions and 11 deletions

View File

@ -214,6 +214,11 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
threadID = DatabaseFactory.getThreadDatabase(this).getOrCreateThreadIdFor(recipient)
}
this.threadID = threadID
val thread = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID)
if (thread == null) {
Toast.makeText(this, "This thread has been deleted.", Toast.LENGTH_LONG).show()
return finish()
}
setUpRecyclerView()
setUpToolBar()
setUpInputBar()
@ -233,6 +238,13 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
scrollToFirstUnreadMessageIfNeeded()
markAllAsRead()
showOrHideInputIfNeeded()
if (this.thread.isOpenGroupRecipient) {
val openGroup = DatabaseFactory.getLokiThreadDatabase(this).getOpenGroupChat(threadID)
if (openGroup == null) {
Toast.makeText(this, "This thread has been deleted.", Toast.LENGTH_LONG).show()
return finish()
}
}
}
override fun onResume() {

View File

@ -96,7 +96,7 @@ class VisibleMessageView : LinearLayout {
profilePictureView.glide = glide
profilePictureView.update()
if (thread.isOpenGroupRecipient) {
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getOpenGroupChat(threadID)!!
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getOpenGroupChat(threadID) ?: return
val isModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, openGroup.room, openGroup.server)
moderatorIconImageView.visibility = if (isModerator) View.VISIBLE else View.INVISIBLE
} else {

View File

@ -154,16 +154,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
}
}
EventBus.getDefault().register(this@HomeActivity)
testDateFormatting()
}
private fun testDateFormatting() {
val timestamp = Date().time
Log.d("Test", getString(R.string.DateUtils_just_now))
Log.d("Test", DateUtils.getFormattedDateTime(timestamp, DateUtils.getHourFormat(this), Locale.getDefault()))
Log.d("Test", DateUtils.getFormattedDateTime(timestamp, "EEE " + DateUtils.getHourFormat(this), Locale.getDefault()))
Log.d("Test", DateUtils.getFormattedDateTime(timestamp, "MMM d " + DateUtils.getHourFormat(this), Locale.getDefault()))
Log.d("Test", DateUtils.getFormattedDateTime(timestamp, "MMM d " + DateUtils.getHourFormat(this) + ", yyyy", Locale.getDefault()))
}
override fun onResume() {

View File

@ -116,6 +116,7 @@ object OpenGroupManager {
val lokiThreadDB = DatabaseFactory.getLokiThreadDatabase(context)
lokiThreadDB.removeOpenGroupChat(threadID)
ThreadUtils.queue {
threadDB.deleteConversation(threadID) // Must be invoked on a background thread
GroupManager.deleteGroup(groupID, context) // Must be invoked on a background thread
}
}