Skip to content

Conversation

@Oaphi
Copy link
Member

@Oaphi Oaphi commented Dec 22, 2025

closes #1930
closes #1932
closes #1933

This PR makes sure following / unfollowing a comment thread bumps the thread's last activity date & time and thus prevents stale content from being served afterwards.

It also fixes confusing inversion of the User#anonymize method's persist_changes parameter (turns out it wasn't the best idea to rename dirty to persist_changes while tired - thankfully, the logic was sound, this change is just a matter of making it not confusing).

Additionally, it ensures attempting to make the same action multiple times does not create duplicate entries (as well as automatically cleans up any duplicate entry on unfollow).

Finally, it also makes sure we don't need to reload the whole page upon successfully unfollowing a thread (and gets us closer to removing thread_unrestrict entirely).

Note for reviewers: to be able to test this change, you need to enable caching in development (should be on by default, but it doesn't hurt to check) and set the PERFORM_CACHING env variable to true.

Oaphi added 16 commits December 21, 2025 17:20
…red it accounts for the last_activity_at column
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.63%. Comparing base (578ef87) to head (8a6e63b).

Files with missing lines Patch % Lines
app/jobs/clean_up_thread_followers_job.rb 85.71% 2 Missing ⚠️
Additional details and impacted files
Components Coverage Δ
controllers 74.66% <100.00%> (ø)
helpers 84.91% <ø> (ø)
jobs 80.59% <85.71%> (+1.35%) ⬆️
models 90.09% <100.00%> (+0.08%) ⬆️
tasks 61.11% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Oaphi Oaphi marked this pull request as ready for review December 22, 2025 02:45
@cellio
Copy link
Member

cellio commented Dec 22, 2025

Would it be easy to also, while we're here, make unfollow leave the in-page thread open, same as follow does? This difference was discussed in chat (pre-existing issue), but I don't know if making them consistent is easy or too much scope creep (and we should file a separate issue for it).

Copy link
Member

@cellio cellio left a comment

Choose a reason for hiding this comment

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

I tested (with the env var per the description) and it's working as expected. The code overall looks good to me; I have one question and would like someone else to review that part.

@Oaphi Oaphi force-pushed the 0valt/1930/comments-last-activity branch from 7346b03 to 74eaa4c Compare December 22, 2025 22:58
Copy link
Contributor

@trichoplax trichoplax left a comment

Choose a reason for hiding this comment

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

Having switched on caching in development as suggested (rails dev:cache from bash inside the container, followed by adding PERFORM_CACHING=true to docker/env, followed by restarting the container), I can reproduce the problem on the develop branch (both the inline thread view and the full thread page can be in a state where clicking "unfollow" appears to have no effect and even a hard refresh doesn't change it to show "follow" (or the other way around)).

On this new branch, the caching problem is fixed so if a page is not matching the server state, refreshing the page fixes it. I see that as fixing the identified problem, so I have approved this pull request, with one minor optional comment.


During testing I noticed a couple of pre-existing problems, so to avoid scope creep I've raised them as separate issues #1932 (which I see you already fixed while I was typing up the other one) and #1933.

Copy link
Member

@cellio cellio left a comment

Choose a reason for hiding this comment

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

LGTM now. Thanks for adding that route so the in-page behavior is the same for follow and unfollow.

@Oaphi Oaphi requested review from cellio and trichoplax December 23, 2025 01:50
Copy link
Member

@cellio cellio left a comment

Choose a reason for hiding this comment

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

Cleanup job LGTM by inspection. Re-approving pending some testing that @trichoplax is going to do. (Test code looks good; I haven't set up the bug conditions for manual testing.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants