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

Improved Search #566

Closed
wants to merge 3 commits into from
Closed

Improved Search #566

wants to merge 3 commits into from

Conversation

Sjmarf
Copy link
Contributor

@Sjmarf Sjmarf commented Sep 2, 2023

Changed the search tab to allow searching of users and posts. This isn't quite done yet, but I wanted to gather some feedback on what I've got so far.



The time results take to load seems to vary; sometimes it can be a little slow. If anyone knows of a way I can speed this up (I'm not too familiar with async stuff), that would be greatly appreciated :)

Things I still need to do:

  • Right now, only 50 results are loaded and it won't load more when you scroll down.
  • Reimplement recent searches.
  • Fix a couple of bugs.
  • Searching comments (may not be in the initial PR, we'll see)
  • Searching instances (definitely won't be in this PR, we need an instance screen first anyway)

@Sjmarf Sjmarf requested a review from a team as a code owner September 2, 2023 19:37
@Sjmarf Sjmarf requested review from mormaer and EricBAndrews and removed request for a team September 2, 2023 19:37
Copy link
Member

@EricBAndrews EricBAndrews left a comment

Choose a reason for hiding this comment

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

Bunch of dead code that can be removed. It would also be nice for maintainability to have a couple comments, especially in the model section

Comment on lines +24 to +62
// @State var pinned: Bool = false

var body: some View {
Group {
HStack {
Text(title)
.font(.title2)
.fontWeight(.semibold)

Spacer()
if searchModel.activeTypeFilter == nil {
Button("See All") {
searchModel.addFilter(filter)
}
.foregroundStyle(Color.accentColor)
.buttonStyle(.borderless)
}
}
.padding(.horizontal, 20)
.padding(.vertical, 6)
// .background(
// ZStack {
// GeometryReader {
// Color.clear.preference(key: ViewOffsetKey.self, value: $0.frame(in: .named("searchArea")).origin.y)
// }
// if pinned {
// Rectangle()
// .fill(.bar)
// .overlay(alignment: .top) {
// Divider()
// }
// }
// }
// )
.foregroundStyle(.primary)
// .onPreferenceChange(ViewOffsetKey.self) {
// // verify if position is zero (pinned) in container coordinates
// self.pinned = Int($0) <= 0
// }
Copy link
Member

Choose a reason for hiding this comment

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

Bunch of dead code in here

}
}

class SearchModel: ObservableObject {
Copy link
Member

Choose a reason for hiding this comment

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

nit

This is a model, so it shouldn't live under the Views tree

content
.background(Color(UIColor.systemGroupedBackground))
.handleLemmyViews()
// .navigationBarColor()
Copy link
Member

Choose a reason for hiding this comment

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

nit

Dead code? Forgot to re-enable?

)
.padding(.bottom, 6)
}
LazyVStack(spacing: 10) { // pinnedViews: [.sectionHeaders]
Copy link
Member

Choose a reason for hiding this comment

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

nit

Dead code

Comment on lines +161 to +188
// if searchModel.activeTypeFilter != nil {
// ProgressView()
// .padding(.top, 15)
// }
Spacer()
.frame(height: 40)
// .background(
// GeometryReader {
// Color.clear.preference(key: ViewOffsetKey.self, value: $0.frame(in: .named("searchArea")).origin.y)
//
// }
// )
// .onPreferenceChange(ViewOffsetKey.self) {
// if $0 < outerGeometry.size.height + 200 {
// if searchModel.loadedPage >= 1 && searchModel.activeTypeFilter != nil && searchModel.page != searchModel.loadedPage + 1 {
// searchModel.page = searchModel.loadedPage + 1
// }
// }
// }
// .task(id: searchModel.page, priority: .userInitiated) {
// print("TASK", searchModel.page, searchModel.loadedPage)
// do {
// try await searchModel.loadMore()
// } catch {
// errorHandler.handle(error)
// }
// }
}
Copy link
Member

Choose a reason for hiding this comment

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

Dead code

Comment on lines +195 to +198
// if !atTopOfScrollView {
// Divider()
// }
}
Copy link
Member

Choose a reason for hiding this comment

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

Dead code

@EricBAndrews
Copy link
Member

EricBAndrews commented Sep 3, 2023

Scrolling performance on searches is also pretty wonky. If you get a bunch of results and scroll, it gets very inconsistent in what posts get rendered--you can scroll for a long time down, then back up super fast.

I've also got a few design thoughts I've opened up in the Slack.

Overall looks really good though!

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 3, 2023

Bunch of dead code that can be removed.

Yep, I'm aware :) As I mentioned, there's still some stuff I needed to fix. Some of that is code that sort-of works for loading more pages, but is too buggy atm. I'll remove/uncomment it before this PR is ready to merge.

It would also be nice for maintainability to have a couple comments, especially in the model section

Sure 👍

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 3, 2023

If you get a bunch of results and scroll, it gets very inconsistent in what posts get rendered--you can scroll for a long time down, then back up super fast.

Yeah. I have a feeling this is caused by the fancy highlighted-text, which does its calculations using .onAppear. Maybe it's not worth using fancy highlighting.

@mormaer
Copy link
Collaborator

mormaer commented Sep 3, 2023

I haven't had time to review this yet but I notice in the description there is mention of searching instances - would instance search make sense in this area?

The user has selected an instance by this stage, we are looking to add some search functionality on instances but I believe this would be restricted to the onboarding / guest journeys before entering the app at which point they have access to this search which is using the current instances API to perform searches for communities/posts/users/comments etc?

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 3, 2023

I haven't had time to review this yet but I notice in the description there is mention of searching instances - would instance search make sense in this area?

The user has selected an instance by this stage, we are looking to add some search functionality on instances but I believe this would be restricted to the onboarding / guest journeys before entering the app at which point they have access to this search which is using the current instances API to perform searches for communities/posts/users/comments etc?

Of course, it's the least likely category to want to search. It would be all the way at the bottom below every other category. When we implement instance pages, it would make sense to include information about how many users the instance has, as well as potentially an uptime graph if we can find a third-party API for it. If we end up having functionality like that, it's reasonable that some people might want to see this information for instances that they aren't a part of. Hence the search-ability. But yeah, not a priority.

@Sjmarf Sjmarf marked this pull request as draft September 3, 2023 17:38
@mormaer
Copy link
Collaborator

mormaer commented Sep 3, 2023

Of course, it's the least likely category to want to search. It would be all the way at the bottom below every other category. When we implement instance pages, it would make sense to include information about how many users the instance has, as well as potentially an uptime graph if we can find a third-party API for it. If we end up having functionality like that, it's reasonable that some people might want to see this information for instances that they aren't a part of. Hence the search-ability. But yeah, not a priority.

I couldn't picture what would happen when the user tapped an instance result, but general information about it makes sense... once guest mode is in we could let people enter guest mode for the instance from that page, too 😱

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 4, 2023

I couldn't picture what would happen when the user tapped an instance result, but general information about it makes sense... once guest mode is in we could let people enter guest mode for the instance from that page, too 😱

Indeed! Maybe a "sign up" button could go on the instance page if the user is in guest mode too?

The instance sidebar is another bit of information that we don't currently display anywhere, so obviously that'd go in the instance page too. Also an admin list

@Sjmarf Sjmarf mentioned this pull request Sep 12, 2023
@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 24, 2023

Will be replaced by an upcoming PR

@Sjmarf Sjmarf closed this Sep 24, 2023
@Sjmarf Sjmarf mentioned this pull request Sep 24, 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.

3 participants