-
Notifications
You must be signed in to change notification settings - Fork 170
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
Save listing and sort type-preferences in app DB #407
Conversation
Some automatic formatting fixes also made it in.
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) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine.
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") | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thx!
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine.
I'll handle the post ktlint merge, don't worry about that. |
As a later PR, those settings do come back with |
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.