forked from cwtch.im/cwtch-ui
MainActivity return result to not leave dart calls hanging
This commit is contained in:
parent
8f0b73af2a
commit
6392d67332
|
@ -297,24 +297,28 @@ class MainActivity: FlutterActivity() {
|
||||||
val count: Int = call.argument("count") ?: 1
|
val count: Int = call.argument("count") ?: 1
|
||||||
|
|
||||||
result.success(Cwtch.getMessages(profile, conversation.toLong(), indexI.toLong(), count.toLong()))
|
result.success(Cwtch.getMessages(profile, conversation.toLong(), indexI.toLong(), count.toLong()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"SendMessage" -> {
|
"SendMessage" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val message: String = call.argument("message") ?: ""
|
val message: String = call.argument("message") ?: ""
|
||||||
result.success(Cwtch.sendMessage(profile, conversation.toLong(), message))
|
result.success(Cwtch.sendMessage(profile, conversation.toLong(), message))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"SendInvitation" -> {
|
"SendInvitation" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val target: Int = call.argument("target") ?: 0
|
val target: Int = call.argument("target") ?: 0
|
||||||
result.success(Cwtch.sendInvitation(profile, conversation.toLong(), target.toLong()))
|
result.success(Cwtch.sendInvitation(profile, conversation.toLong(), target.toLong()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"ShareFile" -> {
|
"ShareFile" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val filepath: String = call.argument("filepath") ?: ""
|
val filepath: String = call.argument("filepath") ?: ""
|
||||||
result.success(Cwtch.shareFile(profile, conversation.toLong(), filepath))
|
result.success(Cwtch.shareFile(profile, conversation.toLong(), filepath))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
"CreateProfile" -> {
|
"CreateProfile" -> {
|
||||||
|
@ -338,18 +342,21 @@ class MainActivity: FlutterActivity() {
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val indexI: Int = call.argument("index") ?: 0
|
val indexI: Int = call.argument("index") ?: 0
|
||||||
result.success(Data.Builder().putString("result", Cwtch.getMessage(profile, conversation.toLong(), indexI.toLong())).build())
|
result.success(Data.Builder().putString("result", Cwtch.getMessage(profile, conversation.toLong(), indexI.toLong())).build())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"GetMessageByID" -> {
|
"GetMessageByID" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val id: Int = call.argument("id") ?: 0
|
val id: Int = call.argument("id") ?: 0
|
||||||
result.success(Data.Builder().putString("result", Cwtch.getMessageByID(profile, conversation.toLong(), id.toLong())).build())
|
result.success(Data.Builder().putString("result", Cwtch.getMessageByID(profile, conversation.toLong(), id.toLong())).build())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"GetMessageByContentHash" -> {
|
"GetMessageByContentHash" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val contentHash: String = call.argument("contentHash") ?: ""
|
val contentHash: String = call.argument("contentHash") ?: ""
|
||||||
result.success(Data.Builder().putString("result", Cwtch.getMessagesByContentHash(profile, conversation.toLong(), contentHash)).build())
|
result.success(Data.Builder().putString("result", Cwtch.getMessagesByContentHash(profile, conversation.toLong(), contentHash)).build())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"SetMessageAttribute" -> {
|
"SetMessageAttribute" -> {
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
|
@ -517,8 +524,10 @@ class MainActivity: FlutterActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result.success(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// using onresume/onstop for broadcastreceiver because of extended discussion on https://stackoverflow.com/questions/7439041/how-to-unregister-broadcastreceiver
|
// using onresume/onstop for broadcastreceiver because of extended discussion on https://stackoverflow.com/questions/7439041/how-to-unregister-broadcastreceiver
|
||||||
|
|
Loading…
Reference in New Issue