sojorn/_legacy/supabase/migrations/20260114_beacon_vouch_ttl.sql
Patrick Britton 3c4680bdd7 Initial commit: Complete threaded conversation system with inline replies
**Major Features Added:**
- **Inline Reply System**: Replace compose screen with inline reply boxes
- **Thread Navigation**: Parent/child navigation with jump functionality
- **Chain Flow UI**: Reply counts, expand/collapse animations, visual hierarchy
- **Enhanced Animations**: Smooth transitions, hover effects, micro-interactions

 **Frontend Changes:**
- **ThreadedCommentWidget**: Complete rewrite with animations and navigation
- **ThreadNode Model**: Added parent references and descendant counting
- **ThreadedConversationScreen**: Integrated navigation handlers
- **PostDetailScreen**: Replaced with threaded conversation view
- **ComposeScreen**: Added reply indicators and context
- **PostActions**: Fixed visibility checks for chain buttons

 **Backend Changes:**
- **API Route**: Added /posts/:id/thread endpoint
- **Post Repository**: Include allow_chain and visibility fields in feed
- **Thread Handler**: Support for fetching post chains

 **UI/UX Improvements:**
- **Reply Context**: Clear indication when replying to specific posts
- **Character Counting**: 500 character limit with live counter
- **Visual Hierarchy**: Depth-based indentation and styling
- **Smooth Animations**: SizeTransition, FadeTransition, hover states
- **Chain Navigation**: Parent/child buttons with visual feedback

 **Technical Enhancements:**
- **Animation Controllers**: Proper lifecycle management
- **State Management**: Clean separation of concerns
- **Navigation Callbacks**: Reusable navigation system
- **Error Handling**: Graceful fallbacks and user feedback

This creates a Reddit-style threaded conversation experience with smooth
animations, inline replies, and intuitive navigation between posts in a chain.
2026-01-30 07:40:19 -06:00

60 lines
1.4 KiB
PL/PgSQL

-- Auto-expire beacons 12 hours after the most recent vouch
create or replace function update_beacon_expires_at(p_beacon_id uuid)
returns void
language plpgsql
security definer
as $$
declare
last_vouch_at timestamptz;
begin
select max(created_at)
into last_vouch_at
from beacon_votes
where beacon_id = p_beacon_id
and vote_type = 'vouch';
update posts
set expires_at = case
when last_vouch_at is null then null
else last_vouch_at + interval '12 hours'
end
where id = p_beacon_id
and is_beacon = true;
end;
$$;
create or replace function handle_beacon_vote_ttl()
returns trigger
language plpgsql
security definer
as $$
declare
target_beacon_id uuid;
begin
target_beacon_id := coalesce(new.beacon_id, old.beacon_id);
if target_beacon_id is not null then
perform update_beacon_expires_at(target_beacon_id);
end if;
return null;
end;
$$;
drop trigger if exists beacon_vote_ttl_trigger on beacon_votes;
create trigger beacon_vote_ttl_trigger
after insert or update or delete on beacon_votes
for each row
execute function handle_beacon_vote_ttl();
-- Backfill existing beacons with vouches
update posts p
set expires_at = v.last_vouch_at + interval '12 hours'
from (
select beacon_id, max(created_at) as last_vouch_at
from beacon_votes
where vote_type = 'vouch'
group by beacon_id
) v
where p.id = v.beacon_id
and p.is_beacon = true;