mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
Fix forward-reference compile error in CloudBackupScreen CreateDocument queue
Replace the self-referential createDocLauncher.launch() call inside the launcher's own callback with a LaunchedEffect(pendingIndex) pattern. The callback now only advances pendingIndex; the LaunchedEffect reacts to state changes and triggers the next file-save picker launch. Also update richtextUi JitPack hash to f92ef49c9d which has all required submodules available. https://claude.ai/code/session_01MCtBrEDEWfCfzppiGRaKEU
This commit is contained in:
@@ -83,9 +83,10 @@ fun CloudBackupScreen(modifier: Modifier) {
|
||||
// Google Drive sheet state
|
||||
var showGdriveSheet by remember { mutableStateOf(false) }
|
||||
|
||||
// Queue for sequential CreateDocument launches (one per account)
|
||||
// Queue for sequential CreateDocument launches (one per account).
|
||||
// pendingIndex == -1 means idle; >= 0 means a launch is in progress.
|
||||
var pendingExports by remember { mutableStateOf(emptyList<Pair<String, String>>()) }
|
||||
var pendingIndex by remember { mutableIntStateOf(0) }
|
||||
var pendingIndex by remember { mutableIntStateOf(-1) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
launch(Dispatchers.IO) {
|
||||
@@ -105,7 +106,7 @@ fun CloudBackupScreen(modifier: Modifier) {
|
||||
) { uri ->
|
||||
val exports = pendingExports
|
||||
val idx = pendingIndex
|
||||
if (uri != null && idx < exports.size) {
|
||||
if (uri != null && idx >= 0 && idx < exports.size) {
|
||||
val (_, ncryptsec) = exports[idx]
|
||||
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
|
||||
context.contentResolver.openOutputStream(uri)?.use { stream ->
|
||||
@@ -115,20 +116,30 @@ fun CloudBackupScreen(modifier: Modifier) {
|
||||
}
|
||||
val next = idx + 1
|
||||
if (next < exports.size) {
|
||||
// Advance the index; LaunchedEffect below will trigger the next picker launch
|
||||
pendingIndex = next
|
||||
createDocLauncher.launch("${exports[next].first}.ncryptsec")
|
||||
} else {
|
||||
// All done
|
||||
// All done — reset and notify
|
||||
val count = exports.size
|
||||
pendingExports = emptyList()
|
||||
pendingIndex = 0
|
||||
pendingIndex = -1
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.cloud_backup_success, "${exports.size} accounts"),
|
||||
context.getString(R.string.cloud_backup_success, "$count accounts"),
|
||||
Toast.LENGTH_LONG,
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
// When pendingIndex advances to a valid index, open the next file-save picker.
|
||||
// This avoids the forward-reference that would arise from calling createDocLauncher
|
||||
// inside its own initializer lambda.
|
||||
LaunchedEffect(pendingIndex) {
|
||||
if (pendingIndex >= 0 && pendingIndex < pendingExports.size) {
|
||||
createDocLauncher.launch("${pendingExports[pendingIndex].first}.ncryptsec")
|
||||
}
|
||||
}
|
||||
|
||||
// Restore: pick any .ncryptsec file and import it
|
||||
val filePickerLauncher = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
|
||||
uri?.let { fileUri ->
|
||||
@@ -575,10 +586,9 @@ fun CloudBackupScreen(modifier: Modifier) {
|
||||
statusText = ""
|
||||
if (pairs.isNotEmpty()) {
|
||||
pendingExports = pairs
|
||||
// Setting pendingIndex to 0 triggers LaunchedEffect,
|
||||
// which opens the first file-save picker.
|
||||
pendingIndex = 0
|
||||
// Launch the file-save picker for the first account;
|
||||
// the launcher callback chains the rest automatically.
|
||||
createDocLauncher.launch("${pairs[0].first}.ncryptsec")
|
||||
}
|
||||
}
|
||||
}.onFailure { e ->
|
||||
|
||||
@@ -13,7 +13,7 @@ material3 = "1.4.0"
|
||||
nav_version = "2.9.7"
|
||||
quartz = "1.06.3"
|
||||
compose_ui = "1.10.6"
|
||||
richtextUi = "a02a03a3e9"
|
||||
richtextUi = "f92ef49c9d"
|
||||
roomKtx = "2.8.4"
|
||||
securityCryptoKtx = "1.1.0"
|
||||
zxingAndroidEmbedded = "4.3.0"
|
||||
|
||||
Reference in New Issue
Block a user