mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-24 15:15:35 +00:00
android, desktop: prevent migration when network conf wasn't applied (#4615)
* android, desktop: prevent migration when network conf wasn't applied * name of param
This commit is contained in:
committed by
GitHub
parent
b3d15f97f0
commit
1a6245fe51
+4
-1
@@ -529,7 +529,10 @@ object ChatController {
|
||||
suspend fun startChatWithTemporaryDatabase(ctrl: ChatCtrl, netCfg: NetCfg): User? {
|
||||
Log.d(TAG, "startChatWithTemporaryDatabase")
|
||||
val migrationActiveUser = apiGetActiveUser(null, ctrl) ?: apiCreateActiveUser(null, Profile(displayName = "Temp", fullName = ""), ctrl = ctrl)
|
||||
apiSetNetworkConfig(netCfg, ctrl)
|
||||
if (!apiSetNetworkConfig(netCfg, ctrl)) {
|
||||
Log.e(TAG, "Error setting network config, stopping migration")
|
||||
return null
|
||||
}
|
||||
apiSetAppFilePaths(
|
||||
getMigrationTempFilesDirectory().absolutePath,
|
||||
getMigrationTempFilesDirectory().absolutePath,
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ fun SubscriptionStatusIndicator(click: (() -> Unit)) {
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
suspend fun setSubsTotal() {
|
||||
if (chatModel.currentUser.value != null) {
|
||||
if (chatModel.currentUser.value != null && chatModel.controller.hasChatCtrl() && chatModel.chatRunning.value == true) {
|
||||
val r = chatModel.controller.getAgentSubsTotal(chatModel.remoteHostId())
|
||||
if (r != null) {
|
||||
subs = r.first
|
||||
|
||||
+4
-1
@@ -516,8 +516,11 @@ suspend fun initTemporaryDatabase(tempDatabaseFile: File, netCfg: NetCfg): Pair<
|
||||
try {
|
||||
if (ctrl != null) {
|
||||
val user = startChatWithTemporaryDatabase(ctrl, netCfg)
|
||||
return if (user != null) ctrl to user else null
|
||||
if (user != null) return ctrl to user
|
||||
chatCloseStore(ctrl)
|
||||
}
|
||||
File(tempDatabaseFile.absolutePath + "_chat.db").delete()
|
||||
File(tempDatabaseFile.absolutePath + "_agent.db").delete()
|
||||
} catch (e: Throwable) {
|
||||
Log.e(TAG, "Error while starting chat in temporary database: ${e.stackTraceToString()}")
|
||||
}
|
||||
|
||||
+3
-1
@@ -515,7 +515,9 @@ private fun MutableState<MigrationToState?>.prepareDatabase(
|
||||
withLongRunningApi {
|
||||
val ctrlAndUser = initTemporaryDatabase(tempDatabaseFile, netCfg)
|
||||
if (ctrlAndUser == null) {
|
||||
state = MigrationToState.DownloadFailed(0, link, archivePath(), netCfg)
|
||||
// Probably, something wrong with network config or database initialization, let's start from scratch
|
||||
state = MigrationToState.PasteOrScanLink
|
||||
MigrationToDeviceState.save(null)
|
||||
return@withLongRunningApi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user