-
Notifications
You must be signed in to change notification settings - Fork 167
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
Controversial posts and comments #1106
Controversial posts and comments #1106
Conversation
Compatibility is kinda a problem, this will probably only be supported in lemmy 18.3. We will still support 18.0. So, some compatibility checks will need to be added. An implementation that I was thinking about was adding the version all long each sorting type. Then have a getSortingTypes(version) which filters on version. And you can get the version from siteviewmodel. |
hm ok, I'll give it a try |
This would probably mean showing UI components dynamically though which isn't done atm, right? I was thinking of doing it for this sort specifically and show the component conditionally, leaving the older ones unaffected. It would also be useful in the case that controversial votes should be hidden according to enableDownvotes. |
@MV-GH w/ respect to versioning, since controversial won't come until We'll adopt here what we do for the rest of lemmy, called stable mainline. In short:
|
Actually for the sort types it should already do that, But there might be some remnants where it is still hardcoded. I made some changes in this regard. As I foresaw more sort types and it was rather troubling having to trackdown all these hardcoded values.
Yes but you can just use |
How about here for example? I guess we could have a map from component to version with a default value of IconAndTextDrawerItem(
text = stringResource(R.string.dialogs_hot),
icon = Icons.Outlined.LocalFireDepartment,
onClick = { onClickSortType(SortType.Hot) },
highlight = (selectedSortType == SortType.Hot),
)
IconAndTextDrawerItem(
text = stringResource(R.string.dialogs_new),
icon = Icons.Outlined.BrightnessLow,
onClick = { onClickSortType(SortType.New) },
highlight = (selectedSortType == SortType.New),
)
IconAndTextDrawerItem(
text = stringResource(R.string.dialogs_old),
icon = Icons.Outlined.History,
onClick = { onClickSortType(SortType.Old) },
highlight = (selectedSortType == SortType.Old),
)
IconAndTextDrawerItem(
text = stringResource(R.string.dialogs_controversial),
icon = Icons.Outlined.ThumbsUpDown,
onClick = { onClickSortType(SortType.Controversial) },
highlight = (selectedSortType == SortType.Controversial),
)
What I get from this though, is that we can push this to |
Could you not there not do something like this That stable mainline policy will probably only be implemented once 0.19 hits. Could still be far away. One thing you also will be able to do is add the image to the enum so that we don't have to specify it again each time. |
I could, but I would need to create the
You mean the fun getCommentSortTypeIcon(ctx: Context, commentSortType: CommentSortType): androidx.compose.ui.graphics.vector.ImageVector {
// ...
} |
getSortypes(version).intersect(listOf(SortType.Hot, SortType.New, ...)).foreach(
IconAndTextDrawerItem(
text = getLocalizedSortingTypeLongName(ctx, it),
icon = Icons.Outlined.LocalFireDepartment, // Either map, or store it on the enum itself, like we do in NavTab
onClick = { onClickSortType(it) },
highlight = (selectedSortType == it),
)
) |
That looks good, thanks! |
…el, and showing sort type dialogs dynamically according to supported sort types
@MV-GH take a look, I did it a bit differently after all |
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.
Codewise it looks great! I'll test the functionality later.
In SettingsForm for the AccountSettingsActivity, should only be a able to be set to a sortType that the instance supports. So there you need to use that getSupportedSort
types too.
…SortType utils, moved getSupportedSortTypes to the sort type enums, used them in Account settings as well
# Conflicts: # app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt # app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt
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.
Almost there
@@ -125,7 +124,7 @@ fun SettingsForm( | |||
val sendNotificationsToEmail = | |||
rememberBooleanSettingState(luv?.local_user?.send_notifications_to_email ?: false) | |||
val sortTypeNames = remember { | |||
MAP_SORT_TYPE_SHORT_FORM.values.map { ctx.getString(it) } | |||
SortType.getSupportedSortTypes(siteViewModel.siteVersion()).map { ctx.getString(it.shortForm) } |
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.
More needs to be done, currently it selects the right sort type by having this thing the same index as the index in the sorttype. In the future where it would be possible for controversial to be disabled (if downvotes disables). These indexes wont lineup.
A potential solution is keep the list separate. then on the dropdown where you select the sortType you have a onSelect that updates a separate rememberSaveable
that stores that index. Then in the form you have default_sort_type = actualSortTypes[actualSortType.value]
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.
I'm a bit confused by which indexes won't lineup. The one index is the one in the supported sort types list, which is the other one?
What I was thinking about this is to add a second parameter to getSupportedSortTypes with the enableDownvotes boolean, but if I do this now I might as well implement the actual hiding too.
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 list of names gets fed to the dropdownsetting which sets the intsettingstate when you select a name. which is the index of that list
Then in form it uses that index to select a sorttype. If we use the index to get it from the filtered list instead of all the sorttypes then we can pass sortType.ordinal to the form. This way it will always have the right index.
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.
Maybe it's a bit of a clunky solution, I made it so that the sort type returned by the backend is matched to the supported types using indexOf, and then I pass the supported sort type to the form using the index returned by the dropdown.
What do you think?
…hort form which is the same, removed the text field from the SortType enum and used the long form in the Dialogs forms
# Conflicts: # app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt
I removed the dialogue one, and I also removed the text field from the enum and I used the long form in the dialogue form instead |
…ial-posts-and-comments
Could you rebase from main? @dessalines This isn't really a breaking change as it keeps the current behaviour for the current version (inline with the API rework). I am kinda pushy about this because, this removes the hardcoded sorts we already have in place. |
Mmk, I'll start that now. |
Closes #1105