parent
e1cc4c496b
commit
15507afd4c
@ -21,6 +21,7 @@ import javax.inject.Singleton
|
||||
private const val PREFERENCES_NAME = "GitnuroConfig"
|
||||
|
||||
private const val PREF_LATEST_REPOSITORIES_TABS_OPENED = "latestRepositoriesTabsOpened"
|
||||
private const val PREF_LATEST_REPOSITORY_TAB_SELECTED = "latestRepositoryTabSelected"
|
||||
private const val PREF_LAST_OPENED_REPOSITORIES_PATH = "lastOpenedRepositoriesList"
|
||||
private const val PREF_THEME = "theme"
|
||||
private const val PREF_COMMITS_LIMIT = "commitsLimit"
|
||||
@ -77,6 +78,12 @@ class AppSettings @Inject constructor() {
|
||||
preferences.put(PREF_LATEST_REPOSITORIES_TABS_OPENED, value)
|
||||
}
|
||||
|
||||
var latestRepositoryTabSelected: String
|
||||
get() = preferences.get(PREF_LATEST_REPOSITORY_TAB_SELECTED, "")
|
||||
set(value) {
|
||||
preferences.put(PREF_LATEST_REPOSITORY_TAB_SELECTED, value)
|
||||
}
|
||||
|
||||
var latestOpenedRepositoriesPath: String
|
||||
get() = preferences.get(PREF_LAST_OPENED_REPOSITORIES_PATH, "")
|
||||
set(value) {
|
||||
|
@ -39,7 +39,12 @@ class TabsManager @Inject constructor(
|
||||
listOf()
|
||||
|
||||
_tabsFlow.value = repositoriesList.ifEmpty { listOf(newAppTab()) }
|
||||
_currentTab.value = _tabsFlow.value.first()
|
||||
|
||||
val latestSelectedTabPath = appSettings.latestRepositoryTabSelected
|
||||
|
||||
val latestSelectedTab = repositoriesList.firstOrNull { it.path == latestSelectedTabPath }
|
||||
|
||||
_currentTab.value = latestSelectedTab ?: _tabsFlow.value.first()
|
||||
}
|
||||
|
||||
fun addNewTabFromPath(path: String, selectTab: Boolean, tabToBeReplaced: TabInformation? = null) {
|
||||
@ -68,6 +73,12 @@ class TabsManager @Inject constructor(
|
||||
|
||||
fun selectTab(tab: TabInformation) {
|
||||
_currentTab.value = tab
|
||||
|
||||
persistTabSelected(tab)
|
||||
}
|
||||
|
||||
private fun persistTabSelected(tab: TabInformation) {
|
||||
appSettings.latestRepositoryTabSelected = tab.path.orEmpty()
|
||||
}
|
||||
|
||||
fun closeTab(tab: TabInformation) {
|
||||
|
Loading…
Reference in New Issue
Block a user