-
Notifications
You must be signed in to change notification settings - Fork 58
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
issue-1686/navigate event #1704
Conversation
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 fixes the bug which is nice, but it also introduces another bug. More details in my comment below. Message me if you're not sure what I'm trying to get across in my message, because I'm struggling to explain it well. 😊
src/core/store.ts
Outdated
effect: (action) => { | ||
const event = action.payload; | ||
Router.push( | ||
`/organize/${event.organization?.id}/projects/${event.campaign?.id}/events/${event.id}` |
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 breaks when creating an event that isn't part of a project, like this:
- Go to /orgs/1/projects/calendar (the global calendar)
- Go to week view
- Drag to create a block in the calendar
- Click "Create single event"
Expected results:
Should navigate to new event page.
Actual results:
Navigates to new event page, but then also quickly after navigates to URL where campaign ID is undefined
(e.g. /organize/1/projects/undefined/events/82).
There is already code on main
to redirect to a newly created event after creating it in the calendar. That code does not use this middleware approach. I'm not sure which I prefer, but regardless, there should only be one piece of code that does the same thing (right now two redirects are happening).
And regardless of where the redirect happens, it needs to account for events outside of projects. The easiest way to do that is to use the getEventUrl()
utility function.
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.
Aha that was why there was no middleware for eventCreated
! Thank you!
@@ -20,6 +21,10 @@ export default function useCreateEvent(orgId: number): useCreateEventReturn { | |||
eventBody | |||
); | |||
dispatch(eventCreated(event)); | |||
env.router.push( | |||
`/organize/${orgId}/projects/${event.campaign?.id}/events/${event.id}` |
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 think we should always use the getEventUrl()
utility to generate event URLs.
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.
okay!
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.
LGTM now!
Description
This PR fixes a bug that page doesn't navigate to newly created event page.
Screenshots
My.winter.project.Mozilla.Firefox.2023-12-13.16-04-19.mp4
Changes
listenerMiddleware
Notes to reviewer
Related issues
Resolves #1686