From f5539ee7e727c24dd832d8401528b1290ef024ca Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 21:26:30 +0000 Subject: [PATCH 1/8] create "Rebloom" button so end-user can share already exisiting blooms with their followers --- front-end/index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/front-end/index.html b/front-end/index.html index 89d6b13..55aeaee 100644 --- a/front-end/index.html +++ b/front-end/index.html @@ -237,6 +237,10 @@

Share a Bloom

Username +
From dd832a01e67f66b075eba5ffffab70f8795d9079 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 21:28:40 +0000 Subject: [PATCH 2/8] update text inside re-bloom button --- front-end/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/index.html b/front-end/index.html index 55aeaee..29e3fee 100644 --- a/front-end/index.html +++ b/front-end/index.html @@ -238,7 +238,7 @@

Share a Bloom

Username From 54134eea9634b68b3a172803e1c8206a2dc6145a Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 21:41:46 +0000 Subject: [PATCH 3/8] add event listner to Handle rebloom button clicks and increment counter --- front-end/views/home.mjs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/front-end/views/home.mjs b/front-end/views/home.mjs index 85a5cca..6856c3f 100644 --- a/front-end/views/home.mjs +++ b/front-end/views/home.mjs @@ -38,6 +38,25 @@ function homeView() { "bloom-template", createBloom ); + + document.querySelectorAll("[data-action='rebloom']").forEach((button) => { + button.addEventListener("click", async () => { + const bloomArticle = button.closest("[data-bloom]"); + const bloomId = bloomArticle.getAttribute("data-bloom-id"); + + try { + await apiService.rebloom(bloomId); + const counter = button.querySelector("[data-rebloom-count]"); + let count = parseInt(counter.textContent) || 0; + counter.textContent = count + 1; + } catch (error) { + console.error("Unable to rebloom:", error); + } + + }); + + }); + renderOne( state.isLoggedIn, getBloomFormContainer(), From 866afa2f3acd3a33885aa45035ccc7b39c7d84df Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 21:51:24 +0000 Subject: [PATCH 4/8] Create rebloom function that gets the current user and the original bloom ID and add a rebloom entry in blooms data --- backend/endpoints.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/endpoints.py b/backend/endpoints.py index 0e177a0..c55954f 100644 --- a/backend/endpoints.py +++ b/backend/endpoints.py @@ -167,6 +167,21 @@ def send_bloom(): ) +@jwt_required() +def rebloom(bloom_id): + current_user = get_current_user() + original_bloom = blooms.get_bloom(int(bloom_id)) + + if original_bloom is None: + return make_response(jsonify({"success": False, "message": "Bloom not found"}), 404) + + blooms.add_bloom(bloom_id, current_user.username) + rebloom_count = len(original_bloom.get("reblooms", [])) + + return jsonify({"success": True, "rebloom_count": rebloom_count}) + + + def get_bloom(id_str): try: id_int = int(id_str) From 02c9bb12aa4bfdf2cc4c5aa3bb257ca7fdac9a66 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 22:04:25 +0000 Subject: [PATCH 5/8] Add Flask route for rebloom so POST requests go to the rebloom function. --- backend/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/main.py b/backend/main.py index 7ba155f..e5cc547 100644 --- a/backend/main.py +++ b/backend/main.py @@ -12,6 +12,7 @@ register, self_profile, send_bloom, + rebloom, suggested_follows, user_blooms, ) @@ -57,6 +58,7 @@ def main(): app.add_url_rule("/suggested-follows/", view_func=suggested_follows) app.add_url_rule("/bloom", methods=["POST"], view_func=send_bloom) + app.add_url_rule("/blooms//rebloom", methods=["POST"], view_func=rebloom) app.add_url_rule("/bloom/", methods=["GET"], view_func=get_bloom) app.add_url_rule("/blooms/", view_func=user_blooms) app.add_url_rule("/hashtag/", view_func=hashtag) From 01356cba88236a89caba6f25d9c45072aad7d426 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 22:18:05 +0000 Subject: [PATCH 6/8] Connect frontend's rebloom button with its' backend endpoint --- front-end/lib/api.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/front-end/lib/api.mjs b/front-end/lib/api.mjs index f4b5339..c781876 100644 --- a/front-end/lib/api.mjs +++ b/front-end/lib/api.mjs @@ -212,6 +212,11 @@ async function postBloom(content) { } } +async function rebloom(bloomId) { + const token = state.token; + return await __apiRequest(`/blooms/${bloomId}/rebloom`, "POST", {}, token); +} + // ======= USER methods async function getProfile(username) { const endpoint = username ? `/profile/${username}` : "/profile"; From 7ce7120c09883ba3429355998c04169f0096c771 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 22:40:18 +0000 Subject: [PATCH 7/8] update counter --- front-end/views/home.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front-end/views/home.mjs b/front-end/views/home.mjs index 6856c3f..0258207 100644 --- a/front-end/views/home.mjs +++ b/front-end/views/home.mjs @@ -1,4 +1,5 @@ import {renderEach, renderOne, destroy} from "../lib/render.mjs"; +import { apiService } from "../lib/api.mjs"; import { state, getLogoutContainer, @@ -45,10 +46,10 @@ function homeView() { const bloomId = bloomArticle.getAttribute("data-bloom-id"); try { - await apiService.rebloom(bloomId); + const data = await apiService.rebloom(bloomId); const counter = button.querySelector("[data-rebloom-count]"); let count = parseInt(counter.textContent) || 0; - counter.textContent = count + 1; + counter.textContent = data.rebloom_count ?? count + 1; } catch (error) { console.error("Unable to rebloom:", error); } From 6202f94e28cf6432877cd1123c62c79d73b5e514 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 19 Feb 2026 22:55:24 +0000 Subject: [PATCH 8/8] replacing __apiRequest with the helper that is already in use to fix bug anf "rebloom" button fucntions as it's exptected --- front-end/lib/api.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/front-end/lib/api.mjs b/front-end/lib/api.mjs index c781876..9487561 100644 --- a/front-end/lib/api.mjs +++ b/front-end/lib/api.mjs @@ -213,8 +213,13 @@ async function postBloom(content) { } async function rebloom(bloomId) { - const token = state.token; - return await __apiRequest(`/blooms/${bloomId}/rebloom`, "POST", {}, token); + try { + const data = await __apiRequest(`/blooms/${bloomId}/rebloom`, { method: "POST",}); + + return data; + } catch (error) { + return { success: false }; + } } // ======= USER methods @@ -297,6 +302,7 @@ const apiService = { getBlooms, postBloom, getBloomsByHashtag, + rebloom, // User methods getProfile,