error handling if something goes wrong when creating a group

This commit is contained in:
Brice-W 2021-05-17 14:16:04 +10:00
parent 91c3ec6c7d
commit ff50d2f1fd
2 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import android.view.View
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_create_closed_group.*
import network.loki.messenger.R
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
import org.session.libsession.messaging.sending_receiving.MessageSender
import org.session.libsession.messaging.sending_receiving.groupSizeLimit
@ -123,7 +124,10 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderM
openConversationActivity(this, threadID, Recipient.from(this, Address.fromSerialized(groupID), false))
finish()
}
}.failUi {
loaderContainer.fadeOut()
isLoading = false
Toast.makeText(this, it.message, Toast.LENGTH_LONG).show()
}
}
// endregion

View File

@ -54,9 +54,12 @@ fun MessageSender.create(name: String, members: Collection<String>): Promise<Str
for (member in members) {
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
closedGroupControlMessage.sentTimestamp = sentTime
retryIfNeeded(30) {
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member))
}.get()
try {
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member)).get()
} catch (e: Exception) {
deferred.reject(e)
return@queue
}
}
// Add the group to the user's set of public keys to poll for