Add shared scripts functionality with allowedUsers access control#43
Open
coreyloftus wants to merge 5 commits intodevfrom
Open
Add shared scripts functionality with allowedUsers access control#43coreyloftus wants to merge 5 commits intodevfrom
coreyloftus wants to merge 5 commits intodevfrom
Conversation
Implements a new "shared" data source that allows users to access scripts shared with them via the allowedUsers field in Firestore. Scripts in the shared_projects collection are filtered by user email and displayed alongside public and personal scripts. - Add getSharedScripts method to FirestoreService with array-contains query - Update ScriptService to support "shared" data source - Update tRPC router procedures to include "shared" in data source enum - Update frontend hooks and context to support shared scripts - Update NewScriptSelect to fetch and display shared projects Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… components The shared scripts functionality was missing from ScriptViewer, ScriptBox, and ScriptData components, causing them to fail to load character data for shared projects. Added shared data source queries to all components that display scripts. - Add sharedData query to ScriptViewer - Add sharedData query to ScriptBox - Add sharedData query to ScriptData - Update getCurrentData() in all components to check for shared projects Fixes issue where selecting a shared project showed "undefined" for all character names. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The shared_projects collection was using the old data format where each line has a 'characters' array instead of a 'character' string. This caused "undefined" to appear in the script viewer and empty character dropdowns. Added data normalization in getSharedScripts() to convert the old format: - characters: ["Baker"] -> character: "Baker" - Takes first character from array if multiple exist - Preserves all other line properties Added debug logging to help diagnose data structure issues. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added detailed console logs to trace the data from Firestore through the backend services to the frontend components. This will help diagnose the undefined character issue. Logging added to: - FirestoreService.getSharedScripts (already had some) - ScriptService.getSharedScripts (new) - NewScriptSelect component (new) - getCharacterData function (new) Each log shows the data structure at that point in the flow. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The previous normalization was adding the new 'character' field but keeping
the old 'characters' array, causing the frontend to still see undefined
values when accessing line.character.
Updated to use destructuring to remove the old field:
- const { characters, ...rest } = line
- return { ...rest, character: characters[0] }
This ensures the normalized data only has 'character' (singular string) and
not 'characters' (plural array).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements a new "shared" data source that enables users to access scripts shared with them through the
allowedUsersfield in Firestore. This allows script sharing between users without making scripts fully public.Changes
getSharedScripts()method that queries theshared_projectscollection and filters documents using Firestore'sarray-containsoperator on theallowedUsersfieldgetScripts,getScenes,getCharacters,getLines)useScriptDatahook to support "shared" data source with authentication requirementUserConfigtype to include "shared" optionHow It Works
When a user logs in, the app now:
shared_projectsFirestore collectionallowedUsersarray contains the user's emailTest Plan
🤖 Generated with Claude Code