refactor: use by remember and private the functions.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
KaiserBh 2023-11-20 06:02:51 +11:00
parent 389336b823
commit d17aa201d5
No known key found for this signature in database
GPG Key ID: 14D73B142042BBA9

View File

@ -392,14 +392,14 @@ private fun getGoogleDrivePreferences(): List<Preference> {
@Composable
private fun getGoogleDrivePurge(): Preference.PreferenceItem.TextPreference {
val scope = rememberCoroutineScope()
val showPurgeDialog = remember { mutableStateOf(false) }
val context = LocalContext.current
val googleDriveSync = remember { GoogleDriveSyncService(context) }
var showPurgeDialog by remember { mutableStateOf(false) }
if (showPurgeDialog.value) {
if (showPurgeDialog) {
PurgeConfirmationDialog(
onConfirm = {
showPurgeDialog.value = false
showPurgeDialog = false
scope.launch {
val result = googleDriveSync.deleteSyncDataFromGoogleDrive()
when (result) {
@ -415,18 +415,18 @@ private fun getGoogleDrivePurge(): Preference.PreferenceItem.TextPreference {
}
}
},
onDismissRequest = { showPurgeDialog.value = false },
onDismissRequest = { showPurgeDialog = false },
)
}
return Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_google_drive_purge_sync_data),
onClick = { showPurgeDialog.value = true },
onClick = { showPurgeDialog = true },
)
}
@Composable
fun PurgeConfirmationDialog(
private fun PurgeConfirmationDialog(
onConfirm: () -> Unit,
onDismissRequest: () -> Unit,
) {
@ -543,7 +543,7 @@ private fun getAutomaticSyncGroup(syncPreferences: SyncPreferences): Preference.
}
@Composable
fun SyncConfirmationDialog(
private fun SyncConfirmationDialog(
onConfirm: () -> Unit,
onDismissRequest: () -> Unit,
) {