Skip to content

Conversation

@alexose
Copy link
Contributor

@alexose alexose commented Nov 23, 2025

Fixes #1673.

This adds a pagination UI to "Nearby Activity" and to "Location Activity"

image

...

image

This PR also includes pulling out ‎app/views/shared/_activity_item.html.haml into a separate file to avoid code duplication.

A few things to consider before merging:

  • The default is set to 50 per page, but you might want to adjust this
  • The overall limit is set to 2000 (it'll say "2000+" when it hits the limit). I tested it with no limit, and it is surprisingly performant! Up to you if you want to allow users to see the full scope of the data.
  • Possibly adding a ?page= parameter to the URL bar (although this opens up quite a few routing questions that are beyond the scope of this PR)

@alexose alexose force-pushed the release-activity-pagination branch 2 times, most recently from 9a6cd09 to f049159 Compare November 23, 2025 17:30
a.gap {
cursor: default;
text-decoration: none;
pointer-events: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to prevent the '...' in the pagination interface from being underlined/highlighted on mouseover

@alexose alexose force-pushed the release-activity-pagination branch from f049159 to 46504ce Compare November 23, 2025 17:32
@alexose alexose changed the title Add pagination to nearby activity Add pagination to activity lists Nov 23, 2025
%div.m_10[l, :metadata]
= render :partial => 'locations/render_update_metadata', :locals => {:l => l}
- if ENV['AWS_BUCKET_NAME'] && !is_bot?
- if ENV['AWS_BUCKET_NAME'].present? && !is_bot?
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 was getting a lot of errors in my local env related to this, so I just went and made it optional

@alexose alexose force-pushed the release-activity-pagination branch from fac29e9 to 888ef92 Compare November 23, 2025 23:00
// Scroll to the top of the activity content with offset for fixed headers (220px)
let element = $('#recent_location_activity_location_#{location.id}')[0];
let elementPosition = element.getBoundingClientRect().top;
let offsetPosition = elementPosition + window.pageYOffset - 220;
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 don't love the hardcoded 220 here, but it works well enough.

Refactor with location activity

Move javascript to be closer to its friends

Fix nearby activity view closing upon pagination
@alexose alexose force-pushed the release-activity-pagination branch from 888ef92 to e96646d Compare November 23, 2025 23:06
@RyanTG
Copy link
Collaborator

RyanTG commented Nov 27, 2025

Thanks. Will review after the holiday. Once again in the middle of a feature update, but hope to have it done soon.

So far we're happy with not adding pagination to the urls ?page=. We've been suppressing those. It's so dynamic that any link shared would not contain the same information if someone else clicked on it later.

Re: the 220 I'll make sure to look in a mobile view, too, since the search container is a different size there.

- if (!activity.user_name.blank?)
by
%span.bold #{activity.user_name}
.activity_hr
Copy link
Collaborator

Choose a reason for hiding this comment

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

The hr should be outside of the recent_activity_container

@RyanTG
Copy link
Collaborator

RyanTG commented Nov 30, 2025

I'm not yet sure why, but in local dev, when I click "nearby locations" it centers me around Pittsburgh (which is fine), and then I click "nearby activity" it returns No recent map edits within current map view. However, I know that some of the locations in the map view have had activity since 2019.

EDIT: Actually, I'm also seeing this on current upstream/master. So, not something introduced here. Might be a misunderstanding of something on my part. I'll look closer later.

@RyanTG
Copy link
Collaborator

RyanTG commented Nov 30, 2025

EDIT: Actually, I'm also seeing this on current upstream/master. So, not something introduced here. Might be a misunderstanding of something on my part. I'll look closer later.

Ok, nevermind. Seems like it's a local data issue where I didn't populate lat/lon for many user submissions in my dev db. Sorry for noise.

Anyway, this looks good so far to me. I will take another glance tonight or tomorrow and merge. I can adjust some style things. Thanks!

@RyanTG RyanTG merged commit 431f145 into pinballmap:master Dec 1, 2025
2 checks passed
@alexose
Copy link
Contributor Author

alexose commented Dec 1, 2025

Thanks for the merge! Did you want me to put up another PR that fixes the hr placement?

@RyanTG
Copy link
Collaborator

RyanTG commented Dec 1, 2025

No, I adjusted the hr in a subsequent commit. Thanks for adding the pagination! Nice improvement.

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.

Add pagination to nearby activity and location activity

2 participants