Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save listing and sort type-preferences in app DB #407

Merged

Conversation

oscarnylander
Copy link
Contributor

Mostly fixes #399

These settings will still be incorrect if they change in the backend. It might be wise to simply fetch them from the backend and use that value, but this atleast partially solves the problem.

Some automatic formatting fixes also made it in.

Some automatic formatting fixes also made it in.
@oscarnylander oscarnylander requested a review from dessalines as a code owner June 4, 2023 18:15
Comment on lines -80 to +106
var bio by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue(luv?.person?.bio.orEmpty())) }
var bio by rememberSaveable(stateSaver = TextFieldValue.Saver) {
mutableStateOf(TextFieldValue(luv?.person?.bio.orEmpty()))
}
var email by rememberSaveable { mutableStateOf(luv?.local_user?.email.orEmpty()) }
var matrixUserId by rememberSaveable { mutableStateOf(luv?.person?.matrix_user_id.orEmpty()) }
val theme by rememberSaveable { mutableStateOf(luv?.local_user?.theme.orEmpty()) }
val interfaceLang by rememberSaveable { mutableStateOf(luv?.local_user?.interface_language.orEmpty()) }
val interfaceLang by rememberSaveable {
mutableStateOf(luv?.local_user?.interface_language.orEmpty())
}
var avatar by rememberSaveable { mutableStateOf(luv?.person?.avatar.orEmpty()) }
var banner by rememberSaveable { mutableStateOf(luv?.person?.banner.orEmpty()) }
var defaultSortType by rememberSaveable { mutableStateOf(luv?.local_user?.default_sort_type) }
var defaultListingType by rememberSaveable { mutableStateOf(luv?.local_user?.default_listing_type) }
var defaultListingType by rememberSaveable {
mutableStateOf(luv?.local_user?.default_listing_type)
}
var showAvatars by rememberSaveable { mutableStateOf(luv?.local_user?.show_avatars) }
var showNsfw by rememberSaveable { mutableStateOf(luv?.local_user?.show_nsfw ?: false) }
var showScores by rememberSaveable { mutableStateOf(luv?.local_user?.show_scores) }
var showBotAccount by rememberSaveable { mutableStateOf(luv?.local_user?.show_bot_accounts) }
var botAccount by rememberSaveable { mutableStateOf(luv?.person?.bot_account) }
var showReadPosts by rememberSaveable { mutableStateOf(luv?.local_user?.show_read_posts) }
var showNewPostNotifs by rememberSaveable { mutableStateOf(luv?.local_user?.show_new_post_notifs) }
var sendNotificationsToEmail by rememberSaveable { mutableStateOf(luv?.local_user?.send_notifications_to_email) }
var showNewPostNotifs by rememberSaveable {
mutableStateOf(luv?.local_user?.show_new_post_notifs)
}
var sendNotificationsToEmail by rememberSaveable {
mutableStateOf(luv?.local_user?.send_notifications_to_email)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are auto-generated formatting fixes, but they can easily be omitted if desirable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine.

Comment on lines +49 to +58
class AccountSettingsViewModelFactory(
private val repository: AccountRepository
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(AccountSettingsViewModel::class.java)) {
@Suppress("UNCHECKED_CAST")
return AccountSettingsViewModel(repository) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
Copy link
Contributor Author

@oscarnylander oscarnylander Jun 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be auto-generated by Hilt (#388)

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thx!

Comment on lines -80 to +106
var bio by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue(luv?.person?.bio.orEmpty())) }
var bio by rememberSaveable(stateSaver = TextFieldValue.Saver) {
mutableStateOf(TextFieldValue(luv?.person?.bio.orEmpty()))
}
var email by rememberSaveable { mutableStateOf(luv?.local_user?.email.orEmpty()) }
var matrixUserId by rememberSaveable { mutableStateOf(luv?.person?.matrix_user_id.orEmpty()) }
val theme by rememberSaveable { mutableStateOf(luv?.local_user?.theme.orEmpty()) }
val interfaceLang by rememberSaveable { mutableStateOf(luv?.local_user?.interface_language.orEmpty()) }
val interfaceLang by rememberSaveable {
mutableStateOf(luv?.local_user?.interface_language.orEmpty())
}
var avatar by rememberSaveable { mutableStateOf(luv?.person?.avatar.orEmpty()) }
var banner by rememberSaveable { mutableStateOf(luv?.person?.banner.orEmpty()) }
var defaultSortType by rememberSaveable { mutableStateOf(luv?.local_user?.default_sort_type) }
var defaultListingType by rememberSaveable { mutableStateOf(luv?.local_user?.default_listing_type) }
var defaultListingType by rememberSaveable {
mutableStateOf(luv?.local_user?.default_listing_type)
}
var showAvatars by rememberSaveable { mutableStateOf(luv?.local_user?.show_avatars) }
var showNsfw by rememberSaveable { mutableStateOf(luv?.local_user?.show_nsfw ?: false) }
var showScores by rememberSaveable { mutableStateOf(luv?.local_user?.show_scores) }
var showBotAccount by rememberSaveable { mutableStateOf(luv?.local_user?.show_bot_accounts) }
var botAccount by rememberSaveable { mutableStateOf(luv?.person?.bot_account) }
var showReadPosts by rememberSaveable { mutableStateOf(luv?.local_user?.show_read_posts) }
var showNewPostNotifs by rememberSaveable { mutableStateOf(luv?.local_user?.show_new_post_notifs) }
var sendNotificationsToEmail by rememberSaveable { mutableStateOf(luv?.local_user?.send_notifications_to_email) }
var showNewPostNotifs by rememberSaveable {
mutableStateOf(luv?.local_user?.show_new_post_notifs)
}
var sendNotificationsToEmail by rememberSaveable {
mutableStateOf(luv?.local_user?.send_notifications_to_email)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine.

@dessalines
Copy link
Member

I'll handle the post ktlint merge, don't worry about that.

@dessalines
Copy link
Member

As a later PR, those settings do come back withGetSite, so it could be updated from the back-end after that initial fetch when you start the app.

@dessalines dessalines merged commit 3e1e968 into LemmyNet:main Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Home Screen-sorting options should respect the users saved default choices
2 participants