mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Add global reset to default
This commit is contained in:
parent
1828e94fae
commit
682b81d936
5 changed files with 37 additions and 3 deletions
|
|
@ -226,7 +226,7 @@ class HomeSettingsService
|
|||
}
|
||||
HomePageResolvedSettings(resolvedRows)
|
||||
} else {
|
||||
createDefault(userId)
|
||||
createDefault()
|
||||
}
|
||||
|
||||
currentSettings.update { resolvedSettings }
|
||||
|
|
@ -235,7 +235,7 @@ class HomeSettingsService
|
|||
/**
|
||||
* Create a default [HomePageResolvedSettings] using the available libraries
|
||||
*/
|
||||
private suspend fun createDefault(userId: UUID): HomePageResolvedSettings {
|
||||
suspend fun createDefault(): HomePageResolvedSettings {
|
||||
Timber.v("Creating default settings")
|
||||
val navDrawerItems = navDrawerItemRepository.getNavDrawerItems()
|
||||
val libraries =
|
||||
|
|
|
|||
|
|
@ -72,13 +72,15 @@ fun HomeRowSettings(
|
|||
|
||||
Options.ViewOptionsUseThumb -> {
|
||||
onViewOptionsChange.invoke(
|
||||
HomeRowViewOptions(
|
||||
viewOptions.copy(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
spacing = 20,
|
||||
imageType = ViewOptionImageType.THUMB,
|
||||
aspectRatio = AspectRatio.WIDE,
|
||||
contentScale = PrefContentScale.FIT,
|
||||
episodeImageType = ViewOptionImageType.THUMB,
|
||||
episodeAspectRatio = AspectRatio.WIDE,
|
||||
episodeContentScale = PrefContentScale.FIT,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ fun HomeSettingsGlobal(
|
|||
onClickSave: () -> Unit,
|
||||
onClickLoad: () -> Unit,
|
||||
onClickLoadWeb: () -> Unit,
|
||||
onClickReset: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val firstFocus: FocusRequester = remember { FocusRequester() }
|
||||
|
|
@ -122,6 +123,20 @@ fun HomeSettingsGlobal(
|
|||
modifier = Modifier,
|
||||
)
|
||||
}
|
||||
item {
|
||||
HomeSettingsListItem(
|
||||
selected = false,
|
||||
headlineText = stringResource(R.string.reset),
|
||||
leadingContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.fa_arrows_rotate),
|
||||
fontFamily = FontAwesome,
|
||||
)
|
||||
},
|
||||
onClick = onClickReset,
|
||||
modifier = Modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ fun HomeSettingsPage(
|
|||
viewModel.loadFromRemoteWeb()
|
||||
}
|
||||
},
|
||||
onClickReset = {
|
||||
showConfirmDialog =
|
||||
ShowConfirm(R.string.overwrite_local_settings) {
|
||||
viewModel.resetToDefault()
|
||||
}
|
||||
},
|
||||
modifier = destModifier,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -500,6 +500,17 @@ class HomeSettingsViewModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun resetToDefault() {
|
||||
viewModelScope.launchIO {
|
||||
_state.update { it.copy(loading = LoadingState.Loading) }
|
||||
val result = homeSettingsService.createDefault()
|
||||
_state.update {
|
||||
it.copy(rows = result.rows)
|
||||
}
|
||||
fetchRowData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class HomePageSettingsState(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue