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

Respect date filter in event list for multi day events #2007

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

thecalcc
Copy link
Contributor

SDESK-7310

groups={groups}
groups={groups.filter((group) => {
const groupDateToMoment = moment(group.date);
const dateFilter = currentSearch.advancedSearch?.dates?.start;
Copy link
Member

Choose a reason for hiding this comment

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

does this view only get rendered in search?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gets rendered in Combined, Planning only and Event only views

Copy link
Member

Choose a reason for hiding this comment

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

Only in search mode? You're filtering out items that don't have some search filters. What if user isn't in search mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If user isn't in search mode the filter would be pointless. Good point, I'll add a check beforehand so we don't iterate needlessly, we can pass the items right away

Copy link
Member

Choose a reason for hiding this comment

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

image

Needless iteration aside, wouldn't there have been a bug in previous code ^ where if you are not in search mode, there would be no groups visible? Since if dateFilter is null you were returning false from the filter function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, date filter has a default of today, so in theory, it's never null

Copy link
Member

Choose a reason for hiding this comment

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

I see. Still, no filter should mean no filtering should be happening. Which means all items should be returned. Even if all existing code paths return the same result before/after, your latest approach is still better.

There's a good rule of least surprise that I haven't had a chance to mention to you yet that applies here.

Copy link
Member

@tomaskikutis tomaskikutis left a comment

Choose a reason for hiding this comment

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

@thecalcc
Copy link
Contributor Author

thecalcc commented Jul 1, 2024

@tomaskikutis added a comment & pushed changes

@thecalcc thecalcc merged commit 23407e3 into superdesk:develop Jul 1, 2024
12 checks passed
@petrjasek petrjasek added this to the 2.7.1 milestone Jul 3, 2024
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