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

feat: search trips #11

Merged
merged 1 commit into from
Jan 6, 2025
Merged

feat: search trips #11

merged 1 commit into from
Jan 6, 2025

Conversation

binarybaba
Copy link
Contributor

@binarybaba binarybaba commented Dec 30, 2024

Helps user plan a journey
This is for people like me who likes to check commute distance very frequently.

While writing this, a lot of code was duplicated from the original SearchPage. There is a serious need for refactor. I didn't want to do it straightaway and risk touching other parts of the code as well. However, if this feature is merged (or if we wanna do this in this PR?), we could do some significant improvements and refacors

Screenshots

image
image

implements #10

@binarybaba binarybaba changed the title feat: plan Journey feat: plan trip Dec 30, 2024
@binarybaba
Copy link
Contributor Author

@rosvik Lemme know if you think I should improve things in this PR or take it up in a follow up 🙌

@rosvik
Copy link
Owner

rosvik commented Jan 2, 2025

@binarybaba I've been wanting to add trip search to the extension for a while now, but never gotten around to it, so I really appreciate you making this 💯 I've played around with it a bit now, and it works great! I'm looking over the code, and will get back to you ASAP with some minor comments.

For now, I wonder if you agree that we can make one simplification on the flow (from #10):

Page: Flip direction + Leave At/Arrive By + Time

This far, I've thought that the most common use case for the extension would be users that need a quick way to check when the next bus/tram would leave a nearby stop. (e.g. someone about to leave work and want to see if their bus is delayed) Which I think is where Raycast shines: as a fast way to get info, and not necessarily the most feature complete solution. No way we can compete with entur.no on the amount of features, but we might be able to compete on ease of use and speed 🔥

So with this in mind, I think we should drop the settings page, and just have

  • Page: search for Origin
  • Page: search for Destination
  • Page: Results + Details

Maybe there are ways to fit the reverse and time selection options on the results page, with a Dropdown in the search bar to select departure time and an Action to flip direction.

Copy link
Owner

@rosvik rosvik left a comment

Choose a reason for hiding this comment

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

First of all, this is so cool! I love that you were able to fit most of a travel planner in a quite simple Raycast command ✨ I did spot a few points that can be improved, but I'm exited about merging this and and iterating on it further. Initially, I think I'll publish this as a private extension at my org, so I can get feedback from colleagues before it's sent to the Raycast Store.

In addition to the comments below, I noticed there are a few linting issues that can be fixed automatically by running npm run lint -- --fix.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/PlanTrip/AddTripDetails.tsx Outdated Show resolved Hide resolved
src/PlanTrip/Trip.tsx Outdated Show resolved Hide resolved
src/PlanTrip/Trip.tsx Outdated Show resolved Hide resolved
src/PlanTrip/Trip.tsx Outdated Show resolved Hide resolved
src/journeyQuery.ts Outdated Show resolved Hide resolved
src/PlanTrip/Trip.tsx Outdated Show resolved Hide resolved
src/PlanTrip/Trip.tsx Outdated Show resolved Hide resolved
src/api.ts Outdated Show resolved Hide resolved
@binarybaba binarybaba requested a review from rosvik January 4, 2025 17:14
@binarybaba binarybaba changed the title feat: plan trip feat: search trips Jan 4, 2025
@binarybaba
Copy link
Contributor Author

Getting rid of the details screen suddenly made so much more sense. Feels more inline. 🙌

  • It seems we can't have a Form.DatePicker in the search dropdown. I feel maybe we should think some more about it if we must implement it.
  • Same with flipping the direction

So I have removed them completely.
Idk without those this feels so much more succint and right! 🤷🏻

Copy link
Owner

@rosvik rosvik left a comment

Choose a reason for hiding this comment

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

Awesome! This feels surprisingly nice to use now 😄

Noticed a couple of minor details while reading through this a second time. Other than that, this looks ready to merge 🚀

src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
];
}
const accessories: Accessory[] = trip.legs
.filter((leg) => !(leg.mode === "foot" && leg.fromPlace.name === leg.toPlace.name))
Copy link
Owner

Choose a reason for hiding this comment

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

It's more precise to use stop ID for this. (We should be able to fetch id instead of name in the query)

Suggested change
.filter((leg) => !(leg.mode === "foot" && leg.fromPlace.name === leg.toPlace.name))
.filter((leg) => !(leg.mode === "foot" && leg.fromPlace.id === leg.toPlace.id))

Copy link
Contributor Author

@binarybaba binarybaba Jan 5, 2025

Choose a reason for hiding this comment

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

id unfortunately doesn't exist in Place. It seems Place in Leg doesn't implement PlaceInterface
StopPlace does implement PlaceInterface. 🤔

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, my bad. We'll have to use fromPlace.quay.stopPlace.id then. (quay.stopPlace gives the parent stop place of the quay)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll pick this one up soon!

src/utils.ts Show resolved Hide resolved
src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
src/SearchTrips/Trip.tsx Outdated Show resolved Hide resolved
@binarybaba binarybaba requested a review from rosvik January 5, 2025 23:18
Helps user to plan a journey

- page: search origin
- page: search destination
- page: list trips (with details)

This is for people like me who likes to check commute distance very frequently.

While writing this, a lot of code was duplicated from the original `SearchPage`. There is a serious need for refactor. I didn't want to do it straightaway and risk touching other parts of the code as well. However, if this feature is merged, we could ideally create a standalone generic enough search page which:
- only searches for venue
- gets Primary action from parent,
- gets all other actions from a common file (so all commands can have the same common actions for consistency)
- possibly use inbuilt throttle of `List`

resolves rosvik#10
Copy link
Owner

@rosvik rosvik left a comment

Choose a reason for hiding this comment

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

Love it. I'm itching to get this merged so I can start using it myself, so I think I will 😄 Of course, feel free to make follow up PRs if you notice something you would like to change.

Thank you so much for making this 🚀

@rosvik rosvik merged commit 434c153 into rosvik:main Jan 6, 2025
@rosvik rosvik linked an issue Jan 6, 2025 that may be closed by this pull request
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.

Feature request: Plan Trip
2 participants