Added git manager scope cancellation on disposal of the tab
This commit is contained in:
parent
5ab88ecce0
commit
239d004b84
@ -337,6 +337,10 @@ class GitManager @Inject constructor(
|
|||||||
refreshRepositoryInfo()
|
refreshRepositoryInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dispose() {
|
||||||
|
managerScope.cancel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import androidx.compose.runtime.*
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.DefaultAlpha
|
import androidx.compose.ui.graphics.DefaultAlpha
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -25,7 +24,6 @@ import app.LoadingRepository
|
|||||||
import app.git.GitManager
|
import app.git.GitManager
|
||||||
import app.git.RepositorySelectionStatus
|
import app.git.RepositorySelectionStatus
|
||||||
import app.theme.tabBackground
|
import app.theme.tabBackground
|
||||||
import app.ui.components.DialogBox
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
|
|
||||||
@ -37,9 +35,15 @@ fun AppTab(
|
|||||||
repositoryPath: String?,
|
repositoryPath: String?,
|
||||||
tabName: MutableState<String>
|
tabName: MutableState<String>
|
||||||
) {
|
) {
|
||||||
LaunchedEffect(gitManager) {
|
DisposableEffect(gitManager) {
|
||||||
if (repositoryPath != null)
|
if (repositoryPath != null)
|
||||||
gitManager.openRepository(repositoryPath)
|
gitManager.openRepository(repositoryPath)
|
||||||
|
|
||||||
|
// TODO onDispose sometimes is called when changing tabs, therefore losing the tab state
|
||||||
|
onDispose {
|
||||||
|
println("onDispose called for $tabName")
|
||||||
|
gitManager.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val errorManager = remember(gitManager) { // TODO Is remember here necessary?
|
val errorManager = remember(gitManager) { // TODO Is remember here necessary?
|
||||||
|
Loading…
Reference in New Issue
Block a user