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

Follower sorting #6184

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

hipstersmoothie
Copy link

@hipstersmoothie hipstersmoothie commented Nov 9, 2024

I think putting followers at the top and bottom in certain situations leads to easier to use UI. I was initially going to do separate PRs but realized that I needed the sorting function. I applied it to some places where I think it makes sense. There may be more

Note: For examples I follow luna

  1. Starter packs get followed people sorted to the bottom

CleanShot 2024-11-09 at 01 45 16@2x

  1. When mention a user, followed people are at the top

CleanShot 2024-11-09 at 01 46 28@2x

  1. Mobile searches sort followed people to the top

CleanShot 2024-11-09 at 01 47 29@2x

  1. Desktop searches sort followed people to the top

CleanShot 2024-11-09 at 01 48 08@2x

@hipstersmoothie hipstersmoothie changed the title sort Sort unfollowed people to the start of start pack lists Nov 9, 2024
@hipstersmoothie hipstersmoothie changed the title Sort unfollowed people to the start of start pack lists Follower sorting Nov 9, 2024
(cherry picked from commit 96a5969111329dfc333224162505acbf302d8c19)
(cherry picked from commit bd8f8f1090564d1ce0c6de848ccc6e46c5c86adc)
(cherry picked from commit 1ffdff0590d2a77a189357633ab8d0edb683868f)
@@ -96,3 +98,19 @@ export function isPlainObject(o: any): o is Object {
function hasObjectPrototype(o: any): boolean {
return Object.prototype.toString.call(o) === '[object Object]'
}

export function sortProfiles(
Copy link
Author

Choose a reason for hiding this comment

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

Wasn't sure where to put this function.

@mary-ext
Copy link
Contributor

mary-ext commented Nov 9, 2024

are you sure 2-4 is actually necessary? in all of the API requests I've made, the AppView always returns who you follow first, and it's been this way since the end of invite-only period

worth noting that the sorting means that in lists where pagination is involved, if there were indeed profiles you follow that weren't in the first page, you just won't see them at all because it'll be sorted to the top, meanwhile you're at the bottom of the list.

if this was indeed a problem, this should've been made at the AppView-level, not the app, or at the very least the sorting should not be done after flattening the paginated list.

@hipstersmoothie
Copy link
Author

I can move 2-4 to another pr but I would like to see them fixed

the AppView always returns who you follow first, and it's been this way since the end of invite-only period

I'm unsure where the data is coming from but in the app none of these lists are sorted like that.

in lists where pagination is involved

I don't think I touched any paginated list?

if this was indeed a problem, this should've been made at the AppView-level, not the app, or at the very least the sorting should not be done after flattening the paginated list.

Can you point me towards where is should make the change?

@mary-ext
Copy link
Contributor

mary-ext commented Nov 9, 2024

Ah, sorry for that, I thought the starter packs had paginated queries but I forgot that's not the case.

@@ -151,7 +156,7 @@ const MentionList = forwardRef<MentionListRef, SuggestionProps>(
<div className="items">
<View style={[pal.borderDark, pal.view, styles.container]}>
{items.length > 0 ? (
items.map((item, index) => {
items.sort(sortProfiles).map((item, index) => {
Copy link
Collaborator

@gaearon gaearon Nov 23, 2024

Choose a reason for hiding this comment

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

sort is mutative so we can't do it here. it would have to be cloned first.

ideally, if the server response isn't appropriately sorted but we want it to be sorted, we'd place this logic closest to where the response is being parsed — i.e. in the query. mind doing that?

@@ -1006,7 +1007,7 @@ let AutocompleteResults = ({
}
style={{borderBottomWidth: 1}}
/>
{autocompleteData?.map(item => (
{autocompleteData?.sort(sortProfiles).map(item => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

same, can't mutate while rendering. doing it in the query before returning is ok.

@@ -206,7 +207,7 @@ export function DesktopSearch() {
: undefined
}
/>
{autocompleteData?.map(item => (
{autocompleteData?.sort(sortProfiles).map(item => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

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

seems like a good idea, pls see comments

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.

3 participants