remove dismissing an update

This commit is contained in:
qimiko committed 2024-06-18 05:19:55 -07:00
1 parent 50f4a5d8e3
commit 70934a95ad
3 files changed
+7 -39

No files matched your search

@@ -61,7 +61,7 @@ fun downloadLauncherUpdate(context: Context) {
} }
@Composable @Composable
fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDismiss: () -> Unit) { fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String) {
val context = LocalContext.current val context = LocalContext.current
ElevatedCard(modifier) { ElevatedCard(modifier) {
@@ -80,19 +80,12 @@ fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDis
modifier = Modifier.padding(horizontal = 10.dp) modifier = Modifier.padding(horizontal = 10.dp)
) )
Row(modifier = Modifier.align(Alignment.End)) { TextButton(
TextButton(onClick = onDismiss) { onClick = { downloadUrl(context, openTo) },
Text(stringResource(R.string.launcher_update_dismiss)) modifier = Modifier.align(Alignment.End)
} ) {
Text(stringResource(R.string.launcher_download))
Spacer(Modifier.size(4.dp))
TextButton(onClick = { downloadUrl(context, openTo) }) {
Text(stringResource(R.string.launcher_download))
}
} }
} }
} }
} }
@@ -263,10 +256,7 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
LauncherUpdateIndicator( LauncherUpdateIndicator(
modifier = modifier, modifier = modifier,
openTo = updateUrl, openTo = updateUrl
onDismiss = {
releaseViewModel.dismissLauncherUpdate()
}
) )
} }
} }
@@ -91,15 +91,6 @@ class ReleaseManager private constructor(
} }
} }
fun dismissLauncherUpdate() {
val update = availableLauncherUpdate.value ?: return
val sharedPreferences = PreferenceUtils.get(applicationContext)
sharedPreferences.setString(PreferenceUtils.Key.LAST_DISMISSED_UPDATE, update.tagName)
_availableLauncherUpdate.value = null
}
private suspend fun getLatestRelease(): Release? { private suspend fun getLatestRelease(): Release? {
val sharedPreferences = PreferenceUtils.get(applicationContext) val sharedPreferences = PreferenceUtils.get(applicationContext)
val useNightly = sharedPreferences.getBoolean(PreferenceUtils.Key.RELEASE_CHANNEL) val useNightly = sharedPreferences.getBoolean(PreferenceUtils.Key.RELEASE_CHANNEL)
@@ -167,13 +158,6 @@ class ReleaseManager private constructor(
} }
private fun checkLauncherUpdate(launcherUpdate: Release) { private fun checkLauncherUpdate(launcherUpdate: Release) {
val sharedPreferences = PreferenceUtils.get(applicationContext)
val lastDismissedVersion = sharedPreferences.getString(PreferenceUtils.Key.LAST_DISMISSED_UPDATE)
if (!lastDismissedVersion.isNullOrEmpty() && launcherUpdate.tagName == lastDismissedVersion) {
return
}
if (launcherUpdate.tagName != BuildConfig.VERSION_NAME) { if (launcherUpdate.tagName != BuildConfig.VERSION_NAME) {
_availableLauncherUpdate.value = launcherUpdate _availableLauncherUpdate.value = launcherUpdate
} }
@@ -98,10 +98,4 @@ class ReleaseViewModel(private val application: Application): ViewModel() {
syncUiState(releaseFlow) syncUiState(releaseFlow)
} }
} }
fun dismissLauncherUpdate() {
viewModelScope.launch(Dispatchers.IO) {
ReleaseManager.get(application).dismissLauncherUpdate()
}
}
} }