Skip to content

Commit

Permalink
Fix showing ReleaseNotes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Oct 3, 2024
1 parent 40ddb05 commit e66571b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
compileSdk compile_sdk_version
minSdkVersion min_sdk_version
targetSdkVersion compile_sdk_version
versionCode 116
versionCode 117
versionName "0.40.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ReleaseNotesManager(

if (shownForVersion != null) {
return if (Version(currentAppVersion) > Version(shownForVersion)) {
updateShownAppVersion()
true
} else {
false
Expand All @@ -34,7 +33,7 @@ class ReleaseNotesManager(
return false
}

private fun updateShownAppVersion() {
fun updateShownAppVersion() {
localStorage.changelogShownForAppVersion = systemInfoManager.appVersion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ private fun MainScreen(
R.id.releaseNotesFragment,
ReleaseNotesFragment.Input(true)
)
viewModel.whatsNewShown()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class MainViewModel(

updateSettingsBadge()
updateTransactionsTabEnabled()
showWhatsNew()
}

override fun createState() = MainModule.UiState(
Expand All @@ -172,6 +171,7 @@ class MainViewModel(

fun whatsNewShown() {
showWhatsNew = false
releaseNotesManager.updateShownAppVersion()
emitState()
}

Expand All @@ -189,6 +189,11 @@ class MainViewModel(
fun onResume() {
contentHidden = pinComponent.isLocked
emitState()
viewModelScope.launch {
if (!pinComponent.isLocked && releaseNotesManager.shouldShowChangeLog()) {
showWhatsNew()
}
}
}

fun onSelect(mainNavItem: MainNavigation) {
Expand Down Expand Up @@ -359,14 +364,10 @@ class MainViewModel(
emitState()
}

private fun showWhatsNew() {
viewModelScope.launch {
if (releaseNotesManager.shouldShowChangeLog()) {
delay(2000)
showWhatsNew = true
emitState()
}
}
private suspend fun showWhatsNew() {
delay(2000)
showWhatsNew = true
emitState()
}

private fun updateSettingsBadge() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.horizontalsystems.bankwallet.modules.releasenotes

import android.os.Parcelable
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -23,6 +24,8 @@ import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.core.getInput
import io.horizontalsystems.bankwallet.modules.main.MainModule
import io.horizontalsystems.bankwallet.modules.main.MainViewModel
import io.horizontalsystems.bankwallet.modules.markdown.MarkdownContent
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.TranslatableString
Expand Down Expand Up @@ -52,8 +55,13 @@ class ReleaseNotesFragment : BaseComposeFragment() {
fun ReleaseNotesScreen(
closeablePopup: Boolean,
onCloseClick: () -> Unit,
viewModel: ReleaseNotesViewModel = viewModel(factory = ReleaseNotesModule.Factory())
viewModel: ReleaseNotesViewModel = viewModel(factory = ReleaseNotesModule.Factory()),
mainViewModel: MainViewModel = viewModel(factory = MainModule.Factory())
) {
BackHandler() {
mainViewModel.whatsNewShown()
onCloseClick.invoke()
}

Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
Expand All @@ -64,7 +72,10 @@ fun ReleaseNotesScreen(
MenuItem(
title = TranslatableString.ResString(R.string.Button_Close),
icon = R.drawable.ic_close,
onClick = onCloseClick
onClick = {
mainViewModel.whatsNewShown()
onCloseClick.invoke()
}
)
)
)
Expand Down

0 comments on commit e66571b

Please sign in to comment.