Skip to content

Conversation

@sheida-shab
Copy link

-[x] 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

Briefly explain your PR.

✨ Re-bloom Feature Implementation

This PR implements the Re-bloom feature in the Purple Forest application, allowing users to reshare blooms while keeping a clear distinction between original blooms and reblooms. The feature covers backend data modeling, API endpoints, state management, and frontend UI changes, aligning with the architecture of the application.

  1. Feature Overview

Users can re-bloom an existing bloom by pressing a new Re-bloom button.

A rebloom adds the bloom to the user’s feed and their followers’ feeds as if they posted it themselves, but it clearly shows:

Original author of the bloom

User who rebloomed it

Each bloom displays rebloom count and last rebloomed timestamp when applicable.

Profile pages continue to display only original blooms; reblooms are shown only in the Home Feed.

  1. Database Changes

A new table reblooms was created to track reblooms:

Column Type Notes
id bigint Primary key
original_bloom_id bigint Foreign key to blooms, not null
rebloomed_by integer User ID who performed the rebloom, not null
rebloomed_at timestamp without timezone Timestamp of rebloom, default CURRENT_TIMESTAMP

Unique constraint ensures a user cannot rebloom the same bloom twice.

  1. Backend / API Changes

Endpoints added:

POST /rebloom/<bloom_id> → creates a rebloom if it doesn’t exist for the user

GET /reblooms/user/ → fetches reblooms made by a specific user

Bloom data model updates:

Added optional fields: rebloomer, rebloom_count, last_rebloomed_at

New backend functions:

has_user_rebloomed(original_bloom_id, user_id) → checks if user already rebloomed

add_rebloom(original_bloom_id, user_id) → inserts a rebloom record

get_reblooms_for_user(username) → fetches all reblooms by a user as Bloom objects

Feed query updates:

get_blooms_for_user now includes rebloom count and last rebloom timestamp

Reblooms are merged into the feed and ordered by their rebloom timestamp for proper timeline display

  1. Frontend Changes

Timeline component (timeline.mjs):

createBloomWithRebloom() renders rebloom info if available: rebloomer, count, and timestamp

Adds a Re-bloom button to each bloom that supports reblooming via event delegation

Home view (home.mjs):

Listens for rebloom button clicks

Calls API to perform rebloom and refreshes timeline and profile state

API service updates:

rebloom(bloomId) function handles rebloom requests and updates state accordingly

  1. State Management

State is updated via central state object, following the existing SSOT and unidirectional data flow.

Reblooms trigger state-change events to automatically re-render the Home Feed.

  1. Summary of Changes

New database table to track reblooms

API endpoints for creating and fetching reblooms

Bloom model updates to include rebloom metadata

Feed and timeline rendering now supports rebloom information

Frontend event handling for rebloom actions

Profile pages unchanged – reblooms excluded

This implementation ensures a clear distinction between original blooms and reblooms, preserves original content, tracks rebloom counts, and integrates seamlessly with the existing Purple Forest SPA architecture.

- Create table 'reblooms' to track user reblooms (schema.sql)
- Update Bloom model with rebloomer, rebloom_count, last_rebloomed_at (blooms.py)
- Add backend functions: add_rebloom, has_user_rebloomed, get_reblooms_for_user (blooms.py)
- Update get_blooms_for_user query to include rebloom metadata (blooms.py)
- Add API endpoints for creating and fetching reblooms (endpoints.py)
- Register new routes in main.py (/rebloom/<id>, /reblooms/user/<username>)
- Add rebloom(bloomId) function in api.mjs for API calls
- Handle rebloom actions and state updates in home.mjs
- Update index.mjs if necessary to trigger state change and re-render Home Feed
- Ensure timeline and profile data refresh correctly after rebloom
- Update timeline.mjs: createBloomWithRebloom() shows rebloomer, rebloom count, last rebloomed time
- Add Re-bloom button to bloom elements and manage its display logic
- Update index.html templates if needed to include rebloom info elements
- Update index.css to style Re-bloom button and rebloom info
@sheida-shab sheida-shab added 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 Feb 10, 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. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant