fix(button): share functionality fixing for collaborative editing - I297#298
Conversation
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
1fd0dcc to
c1394bf
Compare
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
|
I have worked on the Share Functionality for Collaborative Editing, and it's working smoothly now. Given its impact on real-time collaboration, I believe this is a highly valuable feature that should be prioritized. Could you please review the implementation and share your feedback? |
I’ve identified some issue in the client side and cleaned up the client-side code, and the share functionality now works perfectly on locally and deployment too. Shared links generate correctly However, if the 403 Forbidden error still persists on the deployed site |
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
Signed-off-by: Dharma Teja <dteja2468@gmail.com>
| editorValue: string; | ||
| modelCto: string; | ||
| editorModelCto: string; | ||
| data: string; | ||
| editorAgreementData: string; | ||
| agreementHtml: string; | ||
| error: string | undefined; | ||
| samples: Array<Sample>; | ||
| sampleName: string; | ||
| backgroundColor: string; | ||
| textColor: string; | ||
| setTemplateMarkdown: (template: string) => Promise<void>; | ||
| setEditorValue: (value: string) => void; | ||
| setModelCto: (model: string) => Promise<void>; | ||
| setEditorModelCto: (value: string) => void; | ||
| setData: (data: string) => Promise<void>; | ||
| setEditorAgreementData: (value: string) => void; |
There was a problem hiding this comment.
Why were the editor states removed from the app state?
There was a problem hiding this comment.
@DianaLease Thanks for reviewing! I removed editorValue, editorModelCto, and editorAgreementData from store.ts cuz this reduces complexity in syncing editor content and streamline state management. Previously, these duplicate states tracked editor content separately from templateMarkdown, modelCto, and data, which led to sync issues—shared links sometimes reflected stale or partial states because rebuild operated on the processed fields, not the editor ones.
Now Unified them, the editors now directly update templateMarkdown, modelCto, and data, which generateShareableLink compresses into the URL. This ensures shared links always capture the latest editor content, aligning with the root route (/) and preventing partial renders (navbar/footer only), as reported in #297.
One trade-off is that we lose a buffer for unsaved changes if rebuild fails, but the debounced setters mitigate this by delaying updates until valid. I think this simplification is worth it for reliable sharing, What do you think—should I restore them for that use case, or is this approach sufficient for now?
There was a problem hiding this comment.
@DianaLease If this sounds good. I would like you to merge this and see whether this fixes the share functionality in the main site https://playground.accordproject.org/ and could possibly revert the merge if it doesn't.
| }; | ||
| const compressedData = compress(dataToShare); | ||
| return `${window.location.origin}?data=${compressedData}`; | ||
| }, |
There was a problem hiding this comment.
@Vinyl-Davyl Do you remember why we had v1 in this url in the first place?
There was a problem hiding this comment.
I’m not sure why /v1 was there initially—maybe it was intended for versioning or a server-side route? Since the share functionality is client-side (compressing and loading state locally), the root path works perfectly now, as shown in the demo video. The 403 error on the deployed site (template-playground.accordproject.org) suggests a server-side expectation of /v1, but that’s flagged as a separate issue for mentors to handle. @Vinyl-Davyl, if /v1 had a specific purpose (e.g., future API integration), I can adjust this back and tweak App.tsx to handle it differently—let me know!
There was a problem hiding this comment.
@Vinyl-Davyl Do you remember why we had
v1in this url in the first place?
Yeah, I remember this was the reason. #298 (comment)
|
Yeah @DianaLease we had the versioning added while I was building this based off reasons not to use the template archive JSON at the time. So links not to support generation with the format in addition to template archives due to time constraint. As you would probably notice in the Based off mutual agreement with @sanketshevkar and @mttrbrts at the time we suggested looking into versioning the URLs. We started with v1 having a simple object compressed and added to URL(what we have currently). And probably introduce v2 in future to support template archive JSON object format. Of course, We can always go back to no version if there is agreement not to go into considerations for template archive JSON objects for shareables in future at this point. |
|
Given Vinyl-Davyl’s note, we could keep the root path if template archive support isn’t imminent, or revert to |
DianaLease
left a comment
There was a problem hiding this comment.
Thanks, tested in the netlify preview for the PR and it is working as expected there 👍
|
@DianaLease It would work on netlify deploy because the URL is not restricted on netlify deploy on the size of url, can you check once on the playground as well because I still see the same issue. |
|
Yes you were right @nitro56565. This issue just solved the generated link mismatch. And the issue still persists because of the size of the url. Try testing in the playground changing the sample to |
Closes #297
Partially closes #134
This PR resolves the client-side issues with the share functionality in Template Playground, ensuring shared links render the full editor state locally for collaborative editing. The changes align the URL generation with the root route and optimize initialization to prevent partial renders.
Changes
Content.tsx
: Promise<void>return type andvoidoperator fromloadContent, as TypeScript infers it, improving code clarity.contenttocontentDatainsidetryblock to avoid shadowing the state variable.UseShare.tsx
voidfrommessage.successandmessage.errorcalls, as they’re fire-and-forget operations.asyncwith properawaitfornavigator.clipboard.writeText, ensuring clipboard completion before success message.store.ts
generateShareableLinkused/v1?data=..., mismatching the root route (/), causing partial renders (navbar/footer only).isInitializedexisted but wasn’t fully utilized to ensure state readiness beforeApp.tsxrendering.generateShareableLinkto${window.location.origin}?data=${compressedData}, aligning withRoute path="/".dataupdate insidesetData’stryblock, ensuring it only updates on successful rebuild.App.tsx
?data=didn’t redirect to/if on a different path (e.g.,/learn), showing only navbar/footer until manual navigation.isInitializedwas set, risking premature start before shared state loaded.navigate("/", { replace: true })when a shared link is detected, ensuring immediate full render.Flags
Screenshots or Video
Untitled.video.-.Made.with.Clipchamp.7.mp4
Related Issues
Author Checklist
--signoffoption of git commit.mainfromfork:branchname