Skip to content

London| SDC-Nov-2025| Ikenna Agulobi | Sprint 1 | Feature/unfollow#154

Open
ike-agu wants to merge 5 commits intoCodeYourFuture:mainfrom
ike-agu:feature/unfollow
Open

London| SDC-Nov-2025| Ikenna Agulobi | Sprint 1 | Feature/unfollow#154
ike-agu wants to merge 5 commits intoCodeYourFuture:mainfrom
ike-agu:feature/unfollow

Conversation

@ike-agu
Copy link

@ike-agu ike-agu commented Feb 21, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Briefly explain your PR.

This PR implements the Unfollow feature in the Profile component using the existing component-based architecture and single source of truth state pattern.
The Unfollow button:

  • Only appears when the logged-in user is following the profile user
  • Removes the logged-in user from that user’s followers when clicked
  • Updates the UI based on refreshed state from the backend

Changes
Frontend

index.html

  • Added Unfollow button to the profile-template with data-action="unfollow".
    components/profile.mjs
  • Added handleUnfollow handler.
  • Button visibility derived from API state:
    • Hidden when viewing own profile (is_self)
    • Hidden when not following (!is_following)

On click:
Calls apiService.unfollowUser(username)
Refreshes profile and suggestion state

api.mjs

  • Implemented unfollowUser(username):
    • Sends POST /unfollow with { unfollow_username: username }

Backend
main.py
Added POST /unfollow route.

endpoints.py
Implemented do_unfollow():

  • Validates request body
  • Looks up target user
  • Calls data.follows.unfollow(...)
  • Returns { success: true }

data/follows.py

  • Implemented unfollow(follower, followee):
    • Deletes relationship via DELETE FROM follows WHERE follower=? AND followee=?
  1. End-to-End Flow
    /profile/ returns:
  • followers, follows
  • is_following, is_self
  1. Profile component renders button visibility from state.
  2. Clicking Unfollow:
  • Removes follow relationship in DB
  • Re-fetches profile data
  • UI updates automatically from state

How to Test
Automated

  • npx playwright test

Manual

  1. Sign up two users (e.g. sample, AnotherUser)
  2. Log in as sample
  3. Visit /#/profile/AnotherUser
  4. Click Follow → Unfollow button appears
  5. Click Unfollow → follower count updates and Unfollow disappears

@ike-agu ike-agu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Feb 28, 2026
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

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

The code for the actual change is good, but

  1. You've disabled security to allow the tests to run. You can't do that.
  2. You've included changes from other backlog tasks as well. That's poor discipline.

hashtags = [word[1:] for word in content.split(" ") if word.startswith("#")]

now = datetime.datetime.now(tz=datetime.UTC)
now = datetime.now(timezone.utc)

Choose a reason for hiding this comment

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

I'm unaware that the backlog asked for any time refactoring. Putting un-asked-for changes into the code base is not popular with product owners and development team managers.

CORS(
app,
supports_credentials=True,
supports_credentials=False,

Choose a reason for hiding this comment

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

This is a change to the security policy of a website in a PR unrelated to security. No, no, no, no. Just don't.

charset-normalizer==3.4.2
click==8.1.8
cryptography==44.0.1
cryptography==43.0.3

Choose a reason for hiding this comment

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

You've downgraded cryptographic support. Why?

},
mode: "cors",
credentials: "include",
// credentials: "include",

Choose a reason for hiding this comment

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

Again. No. You're hacking the security in an unrelated PR.

state.updateState({
hashtagBlooms: blooms,
currentHashtag: `#${tag}`,
currentHashtag: hashtag,

Choose a reason for hiding this comment

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

What's this change doing here?

@@ -0,0 +1,33 @@
import { test, expect } from "@playwright/test";

Choose a reason for hiding this comment

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

Is the test file for a different backlog item?

@@ -0,0 +1,30 @@
import { test, expect } from "@playwright/test";
import { loginAsSample, signUp } from "./test-utils.mjs";

Choose a reason for hiding this comment

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

Nice - most trainees didn't add tests for this. I'm guessing this is why you disabled a lot of the security, so the tests could run? Not a good thing to do! Google/AI can walk you through the "right" way to make Playwright tests work with a CORS enabled website.


apiService.getBloomsByHashtag(hashtag);
if (hashtag !== state.currentHashtag) {
await apiService.getBloomsByHashtag(hashtag);

Choose a reason for hiding this comment

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

Is this in the right PR?

{
"status": "failed",
"failedTests": []
} No newline at end of file

Choose a reason for hiding this comment

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

Unusual to check in test results.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Purple Forest Kanban Feb 28, 2026
@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants