mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
Merge branch 'master' into master-android
This commit is contained in:
+16
-3
@@ -461,12 +461,11 @@ object ChatController {
|
||||
Log.d(TAG, "user: $user")
|
||||
try {
|
||||
apiSetNetworkConfig(getNetCfg())
|
||||
val justStarted = apiStartChat()
|
||||
appPrefs.chatStopped.set(false)
|
||||
val chatRunning = apiCheckChatRunning()
|
||||
val users = listUsers(null)
|
||||
chatModel.users.clear()
|
||||
chatModel.users.addAll(users)
|
||||
if (justStarted) {
|
||||
if (!chatRunning) {
|
||||
chatModel.currentUser.value = user
|
||||
chatModel.localUserCreated.value = true
|
||||
getUserChatData(null)
|
||||
@@ -485,6 +484,8 @@ object ChatController {
|
||||
}
|
||||
Log.d(TAG, "startChat: running")
|
||||
}
|
||||
apiStartChat()
|
||||
appPrefs.chatStopped.set(false)
|
||||
} catch (e: Throwable) {
|
||||
Log.e(TAG, "failed starting chat $e")
|
||||
throw e
|
||||
@@ -738,6 +739,15 @@ object ChatController {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun apiCheckChatRunning(): Boolean {
|
||||
val r = sendCmd(null, CC.CheckChatRunning())
|
||||
when (r) {
|
||||
is CR.ChatRunning -> return true
|
||||
is CR.ChatStopped -> return false
|
||||
else -> throw Exception("failed check chat running: ${r.responseType} ${r.details}")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun apiStopChat(): Boolean {
|
||||
val r = sendCmd(null, CC.ApiStopChat())
|
||||
when (r) {
|
||||
@@ -2709,6 +2719,7 @@ sealed class CC {
|
||||
class ApiUnmuteUser(val userId: Long): CC()
|
||||
class ApiDeleteUser(val userId: Long, val delSMPQueues: Boolean, val viewPwd: String?): CC()
|
||||
class StartChat(val mainApp: Boolean): CC()
|
||||
class CheckChatRunning: CC()
|
||||
class ApiStopChat: CC()
|
||||
@Serializable
|
||||
class ApiSetAppFilePaths(val appFilesFolder: String, val appTempFolder: String, val appAssetsFolder: String, val appRemoteHostsFolder: String): CC()
|
||||
@@ -2854,6 +2865,7 @@ sealed class CC {
|
||||
is ApiUnmuteUser -> "/_unmute user $userId"
|
||||
is ApiDeleteUser -> "/_delete user $userId del_smp=${onOff(delSMPQueues)}${maybePwd(viewPwd)}"
|
||||
is StartChat -> "/_start main=${onOff(mainApp)}"
|
||||
is CheckChatRunning -> "/_check running"
|
||||
is ApiStopChat -> "/_stop"
|
||||
is ApiSetAppFilePaths -> "/set file paths ${json.encodeToString(this)}"
|
||||
is ApiSetEncryptLocalFiles -> "/_files_encrypt ${onOff(enable)}"
|
||||
@@ -3007,6 +3019,7 @@ sealed class CC {
|
||||
is ApiUnmuteUser -> "apiUnmuteUser"
|
||||
is ApiDeleteUser -> "apiDeleteUser"
|
||||
is StartChat -> "startChat"
|
||||
is CheckChatRunning -> "checkChatRunning"
|
||||
is ApiStopChat -> "apiStopChat"
|
||||
is ApiSetAppFilePaths -> "apiSetAppFilePaths"
|
||||
is ApiSetEncryptLocalFiles -> "apiSetEncryptLocalFiles"
|
||||
|
||||
Reference in New Issue
Block a user