Skip to content

London | 26-SDC-March | Zobeir Rigi | Legacy-Code | Sprint 1 | Add ability to unfollow users - #253

Open
Zobeir-Rigi wants to merge 1 commit into
CodeYourFuture:mainfrom
Zobeir-Rigi:add-unfollow-functionality
Open

London | 26-SDC-March | Zobeir Rigi | Legacy-Code | Sprint 1 | Add ability to unfollow users#253
Zobeir-Rigi wants to merge 1 commit into
CodeYourFuture:mainfrom
Zobeir-Rigi:add-unfollow-functionality

Conversation

@Zobeir-Rigi

Copy link
Copy Markdown
  • 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

Bug

Users could follow other users, but had no way to unfollow them.

Fix

Added unfollow functionality by displaying an Unfollow button for followed users and implementing the backend endpoint to remove follow relationships.

@Zobeir-Rigi Zobeir-Rigi added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Legacy-Code The name of the module. labels Jul 4, 2026

@SlideGauge SlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall good job, could you address a couple of notes from my side?

Comment thread backend/data/follows.py
def unfollow(follower: User, followee: User):
with db_cursor() as cur:
cur.execute(
"DELETE FROM follows WHERE follower = %(follower_id)s AND followee = %(followee_id)s",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Parameterized DELETE — correct and injection-safe, and consistent with follow(). Good instinct.

Comment thread backend/main.py
app.add_url_rule("/bloom/<id_str>", methods=["GET"], view_func=get_bloom)
app.add_url_rule("/blooms/<profile_username>", view_func=user_blooms)
app.add_url_rule("/hashtag/<hashtag>", view_func=hashtag)
app.add_url_rule(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could you reformat it to match the surrounding coding style? (overall, even if you want to keep it multiline, the arguments should be indented additionally, like this:

app.add_url_rule(
    "/unfollow/<profile_username>",
    methods=["POST"],
    view_func=do_unfollow)

Comment thread backend/data/follows.py
follower_id=follower.id,
followee_id=followee.id,
),
) No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could you add newline in the end of the file please?

if (!username) return;

await apiService.followUser(username);
if (button.textContent === "Unfollow") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here you decide whether to follow or unfollow by checking button.textContent === "Unfollow". That works right now, but have a think: textContent is the text a human reads on the screen. What happens to this logic the day someone renames the button to "Stop following", or the app gets translated into another language?

You're already storing a piece of state on this button so the handler can read it later — see the data-username attribute a few lines up. Could the follow/unfollow state travel the same way, instead of being inferred from the label? Have a look at how data-username is set and then read back, and see if you can apply the same idea here.

@SlideGauge SlideGauge 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. labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Legacy-Code The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants