mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 12:13:52 +00:00
Fix open group deletion issue
This commit is contained in:
parent
9fd2788664
commit
ecc7f50ac4
@ -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() {
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user