Removed done TODO tasks and added appScope cancellation on app exit
This commit is contained in:
parent
ab9c8ce2df
commit
51ea75c033
@ -44,8 +44,6 @@ class App {
|
||||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
private val appScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
@ -92,7 +90,7 @@ class App {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
appScope.cancel("Closing app")
|
||||
appStateManager.cancelCoroutines()
|
||||
this.exitApplication()
|
||||
}
|
||||
}
|
||||
@ -151,7 +149,7 @@ class App {
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeTab(key: Int) = appScope.launch(Dispatchers.IO) {
|
||||
private fun removeTab(key: Int) = appStateManager.appStateScope.launch(Dispatchers.IO) {
|
||||
// Stop any running jobs
|
||||
val tabs = tabsFlow.value
|
||||
val tabToRemove = tabs.firstOrNull { it.key == key } ?: return@launch
|
||||
@ -164,7 +162,7 @@ class App {
|
||||
tabsFlow.value = tabsFlow.value.filter { tab -> tab.key != key }
|
||||
}
|
||||
|
||||
fun addTab(tabInformation: TabInformation) = appScope.launch(Dispatchers.IO) {
|
||||
fun addTab(tabInformation: TabInformation) = appStateManager.appStateScope.launch(Dispatchers.IO) {
|
||||
tabsFlow.value = tabsFlow.value.toMutableList().apply { add(tabInformation) }
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class AppStateManager @Inject constructor(
|
||||
val latestOpenedRepositoriesPaths: List<String>
|
||||
get() = _latestOpenedRepositoriesPaths
|
||||
|
||||
private val appStateScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) // TODO Stop this when closing the app
|
||||
val appStateScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
val latestOpenedRepositoryPath: String
|
||||
get() = _latestOpenedRepositoriesPaths.firstOrNull() ?: ""
|
||||
@ -74,4 +74,8 @@ class AppStateManager @Inject constructor(
|
||||
_latestOpenedRepositoriesPaths.addAll(repositories)
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelCoroutines() {
|
||||
appStateScope.cancel("Closing app")
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ class DiffViewModel @Inject constructor(
|
||||
private val diffManager: DiffManager,
|
||||
private val statusManager: StatusManager,
|
||||
) {
|
||||
// TODO Maybe use a sealed class instead of a null to represent that a diff is not selected?
|
||||
private val _diffResult = MutableStateFlow<ViewDiffResult>(ViewDiffResult.Loading)
|
||||
val diffResult: StateFlow<ViewDiffResult?> = _diffResult
|
||||
|
||||
|
@ -65,7 +65,6 @@ class LogViewModel @Inject constructor(
|
||||
_logStatus.value = LogStatus.Loaded(hasUncommitedChanges, log, currentBranch, statusSummary)
|
||||
|
||||
// Remove search filter if the log has been updated
|
||||
// TODO: Should we just update the search instead of closing it?
|
||||
_logSearchFilterResults.value = LogSearch.NotSearching
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user