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

Don't do a full page load when clicking the follow button #28872

Merged
merged 1 commit into from Jan 20, 2024

Commits on Jan 20, 2024

  1. Don't do a full page load when clicking the follow button

    - Use htmx to perform the button request
      - `hx-headers='{"x-csrf-token": "{{.CsrfToken}}"}'` to authenticate (we should probably learn to reuse this)
      - `hx-post="{{.ContextUser.HomeLink}}?action=follow"` to send a POST request to follow the user
      - `hx-target="#profile-avatar-card"` to target the card div for replacement
      - `hx-swap="outerHTML"` to replace the card (as opposed to its inner content) with the new card that shows the new follower count and button color
    - Change the backend response to return a `<div>` tag (the card) instead of a redirect to the user page
    
    Signed-off-by: Yarden Shoham <git@yardenshoham.com>
    yardenshoham committed Jan 20, 2024
    Configuration menu
    Copy the full SHA
    492ef18 View commit details
    Browse the repository at this point in the history