Skip to content

Commit 8ea28b1

Browse files
committed
Code review fixes
1 parent 4b4a72b commit 8ea28b1

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/shared/handler/ContainerFileOpeningHandler.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import java.io.File
1313
fun containerFileOpeningHandler(
1414
result: ContainerFileOpeningResult,
1515
nestedFile: MutableState<File?>,
16-
currentNestedFile: MutableState<File?>,
1716
showSivaDialog: MutableState<Boolean>,
1817
showLoadingScreen: MutableState<Boolean>,
1918
context: Context,
@@ -23,7 +22,6 @@ fun containerFileOpeningHandler(
2322
when (result) {
2423
is ContainerFileOpeningResult.OpenNestedFile -> {
2524
nestedFile.value = result.file
26-
currentNestedFile.value = result.file
2725
if (result.needsSivaDialog) {
2826
showSivaDialog.value = true
2927
} else {

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/signing/SigningNavigation.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ fun SigningNavigation(
277277

278278
val showSivaDialog = remember { mutableStateOf(false) }
279279
val nestedFile = rememberSaveable { mutableStateOf<File?>(null) }
280-
val currentNestedFile = rememberSaveable { mutableStateOf<File?>(null) }
281280

282281
val showContainerBottomSheet = remember { mutableStateOf(false) }
283282
val showSignedContainerBottomSheet = remember { mutableStateOf(false) }
@@ -355,7 +354,6 @@ fun SigningNavigation(
355354
}
356355

357356
val onDataFileClick: (DataFileInterface) -> Unit = { dataFile ->
358-
currentNestedFile.value = null
359357
showDataFileBottomSheet.value = false
360358

361359
showLoadingScreen.value = true
@@ -368,7 +366,6 @@ fun SigningNavigation(
368366
containerFileOpeningHandler(
369367
result = result,
370368
nestedFile = nestedFile,
371-
currentNestedFile = currentNestedFile,
372369
showSivaDialog = showSivaDialog,
373370
showLoadingScreen = showLoadingScreen,
374371
context = context,

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/signing/bottomsheet/DataFileBottomSheet.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import android.content.Intent
77
import androidx.activity.result.ActivityResultLauncher
88
import androidx.compose.runtime.Composable
99
import androidx.compose.runtime.MutableState
10-
import androidx.compose.runtime.mutableStateOf
11-
import androidx.compose.runtime.saveable.rememberSaveable
1210
import androidx.compose.ui.Modifier
1311
import androidx.compose.ui.res.stringResource
1412
import ee.ria.DigiDoc.R
@@ -43,15 +41,12 @@ fun DataFileBottomSheet(
4341
openRemoveFileDialog: MutableState<Boolean>,
4442
onBackButtonClick: () -> Unit,
4543
) {
46-
val currentNestedFile = rememberSaveable { mutableStateOf<File?>(null) }
47-
4844
val buttonName = stringResource(id = R.string.button_name)
4945

5046
BottomSheet(
5147
modifier = modifier,
5248
showSheet = showSheet,
5349
onDismiss = {
54-
currentNestedFile.value = null
5550
onDataFileBottomSheetDismiss()
5651
},
5752
buttons =
@@ -73,7 +68,6 @@ fun DataFileBottomSheet(
7368
containerFileOpeningHandler(
7469
result = result,
7570
nestedFile = nestedFile,
76-
currentNestedFile = currentNestedFile,
7771
showSivaDialog = showSivaDialog,
7872
showLoadingScreen = showLoadingScreen,
7973
context = context,

app/src/main/kotlin/ee/ria/DigiDoc/viewmodel/RecentDocumentsViewModel.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RecentDocumentsViewModel
4545
private val mimeTypeResolver: MimeTypeResolver,
4646
private val cdoc2Settings: CDOC2Settings,
4747
) : ViewModel() {
48+
private val logTag = "RecentDocumentsViewModel"
4849
private val _sendToSigningViewWithSiva = MutableLiveData(false)
4950
val sendToSigningViewWithSiva: LiveData<Boolean> = _sendToSigningViewWithSiva
5051

@@ -69,16 +70,22 @@ class RecentDocumentsViewModel
6970
initialValue = _documentList.value,
7071
)
7172

72-
@Throws(Exception::class)
7373
suspend fun openDocument(
7474
document: File,
7575
isSivaConfirmed: Boolean,
76-
): Container =
77-
if (!document.isCryptoContainer()) {
78-
openSignatureDocument(document, isSivaConfirmed)
79-
} else {
80-
openCryptoDocument(document)
76+
): Container? {
77+
return try {
78+
if (!document.isCryptoContainer()) {
79+
openSignatureDocument(document, isSivaConfirmed)
80+
} else {
81+
openCryptoDocument(document)
82+
}
83+
} catch (e: Exception) {
84+
errorLog(logTag, "Unable to open container", e)
85+
_errorState.postValue(R.string.container_load_error)
86+
return null
8187
}
88+
}
8289

8390
@Throws(Exception::class)
8491
suspend fun openSignatureDocument(

libdigidoc-lib/src/main/kotlin/ee/ria/DigiDoc/libdigidoclib/SignedContainer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ class SignedContainer
371371
}
372372

373373
else -> {
374+
errorLog(LOG_TAG, "Unable to open container", e)
374375
throw IOException(e.message)
375376
}
376377
}

0 commit comments

Comments
 (0)