rooms version 1 added #31
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Database Schema Changes (schema.prisma):
Added a new Room model with:
Unique 6-digit code for room identification
One-to-many relationship with Pastes
Created at timestamp
Updated Paste model to include:
Optional relationship to Room
Room ID foreign key
Room Page Implementation (+page.svelte):
Created a dynamic route with room code parameter
Implemented features:
Room header showing room code with copy button
Paste creation form with:
Title input
Language selector
Code editor with preview
File drag-and-drop support
Syntax highlighting using Prism.js
Real-time paste list updates using SvelteKit's reactivity Form handling improvements:
Added enctype="multipart/form-data" for file uploads Reactive form submission with automatic UI updates Form clearing after successful submission
Server-Side Logic (+page.server.js):
Load function to fetch room data:
Retrieves room by code with related pastes
Orders pastes by creation date
Includes error handling for non-existent rooms
Form actions:
createPaste: Handles paste creation in rooms
Validates room existence
Creates paste with room association
UI/UX Features:
Responsive design for all screen sizes
Gradient backgrounds and card-based layout
Interactive elements:
Copy buttons for room code and paste content
File drag-and-drop zone with visual feedback
Code editor/preview toggle
Syntax highlighting for multiple languages
Toast notifications for user feedback
Loading states and error handling
Data Flow Improvements:
Reactive bindings for real-time updates
SvelteKit's form enhancement for smooth submissions Automatic UI updates after paste creation
Optimized data invalidation and reloading
Latest Fixes:
Resolved form submission issues:
Added proper enctype for file uploads
Fixed form clearing after submission
Improved data reactivity:
Added reactive binding for room data
Implemented proper data invalidation
Fixed refresh issues with paste list updates
The feature now provides:
Private rooms identified by 6-digit codes
Real-time paste sharing within rooms
Rich code editing experience
Immediate UI updates without page refreshes
Robust error handling and user feedback
The room feature is now fully functional, allowing users to:
Create or join rooms using codes
Share code snippets in real-time
View and interact with shared pastes
Copy and view detailed paste information