Skip to content

Commit

Permalink
fix: Address PR comments-2
Browse files Browse the repository at this point in the history
  • Loading branch information
omerhabib26 committed May 22, 2024
1 parent d9c54eb commit f6ecde0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/org/openedx/app/AppActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ class AppActivity : AppCompatActivity(), InsetHolder, WindowSizeHolder {
}
}

if (viewModel.canResetAppDirectory){
viewModel.resetAppDirectory(this)
}

viewModel.logoutUser.observe(this) {
profileRouter.restartApp(supportFragmentManager, viewModel.isLogistrationEnabled)
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/org/openedx/app/AppViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class AppViewModel(
private var logoutHandledAt: Long = 0

val isBranchEnabled get() = config.getBranchConfig().enabled
val canResetAppDirectory = preferencesManager.canResetAppDirectory
private val canResetAppDirectory get() = preferencesManager.canResetAppDirectory

override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
setUserId()
if(canResetAppDirectory) {
resetAppDirectory(owner as Context)
}
viewModelScope.launch {
notifier.notifier.collect { event ->
if (event is LogoutEvent && System.currentTimeMillis() - logoutHandledAt > 5000) {
Expand All @@ -63,7 +66,7 @@ class AppViewModel(
)
}

fun resetAppDirectory(context: Context) {
private fun resetAppDirectory(context: Context) {
FileUtil.deleteOldAppDirectory(context)
preferencesManager.canResetAppDirectory = false
}
Expand Down

0 comments on commit f6ecde0

Please sign in to comment.