MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | add unfollow functionality - #6
Open
marissamolejon wants to merge 1 commit into
Open
MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | add unfollow functionality#6marissamolejon wants to merge 1 commit into
marissamolejon wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
adds the ability to unfollow a user. Following existed;
there was no way to reverse it.
Investigation first
Before writing anything, searched the codebase for existing
"unfollow" references:
This found
apiService.unfollowUser(username)already fully writtenin
front-end/lib/api.mjs, POSTing to/unfollow/<username>— butno backend route existed, and no UI element called it. This
meant the actual scope of this issue was smaller than it first
appeared: build the missing backend endpoint, and wire up a button —
no new frontend API logic needed.
Backend
unfollow(follower, followee)infollows.py— aDELETE,naturally idempotent (no
UniqueViolationhandling needed, unlikefollow(), since deleting a row that doesn't exist is a no-op).do_unfollow(username)inendpoints.py— takesusernamefromthe URL path (matching the frontend's existing call and the
pattern used by
other_profile). No request body is sent, so nofield validation applies.
POST /unfollow/<username>route registered inmain.py.Frontend
"Who to follow" suggestion chips — suggested users are, by
definition, not already followed, so an unfollow button there
would never apply).
createProfile()shows the Unfollow button exactly whenis_followingis true — the inverse of the Follow button'sexisting visibility logic, making the two buttons mutually
exclusive.
handleUnfollow(), mirroringhandleFollow(), calling thealready-existing
apiService.unfollowUser().Testing
correctly; idempotent re-unfollow attempt succeeds without error;
unfollowing a nonexistent user returns a 404-style error.
verified live on a real profile page — button correctly toggles
each time, follower counts update correctly in both directions.
Scope
5 files changed, no schema migration needed (uses the existing
followstable). No automated tests added (consistent with priorPRs in this repo — a good candidate for a follow-up test-coverage
pass across all six issues).