fix(android): 修复导出备份后返回启动屏幕的问题
问题原因: - 当文件选择器 (ActivityResultContracts.CreateDocument) 启动时, Android 可能会销毁并重新创建 Activity(配置更改) - startupComplete、pendingExportJson、pendingExportAddress 使用 remember 存储状态,在 Activity 重建时会丢失 - startupComplete 重置为 false 导致显示启动检查屏幕 修复方案: - 将 startupComplete 从 remember 改为 rememberSaveable - 将 pendingExportJson 和 pendingExportAddress 从 remember 改为 rememberSaveable - rememberSaveable 会通过 Android 的 savedInstanceState 机制持久化状态 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2799eb5a3a
commit
c002640911
|
|
@ -13,6 +13,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
|
|
@ -114,8 +115,9 @@ fun TssPartyApp(
|
|||
|
||||
// Export/Import file handling
|
||||
val context = LocalContext.current
|
||||
var pendingExportJson by remember { mutableStateOf<String?>(null) }
|
||||
var pendingExportAddress by remember { mutableStateOf<String?>(null) }
|
||||
// Use rememberSaveable to persist across configuration changes (e.g., file picker activity)
|
||||
var pendingExportJson by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
var pendingExportAddress by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
|
||||
// File picker for saving backup
|
||||
val createDocumentLauncher = rememberLauncherForActivityResult(
|
||||
|
|
@ -180,7 +182,8 @@ fun TssPartyApp(
|
|||
}
|
||||
|
||||
// Track if startup is complete
|
||||
var startupComplete by remember { mutableStateOf(false) }
|
||||
// Use rememberSaveable to persist across configuration changes (e.g., file picker activity)
|
||||
var startupComplete by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
// Handle success messages
|
||||
LaunchedEffect(uiState.successMessage) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue