2424 </div >
2525
2626 <!-- Description -->
27- <p class =" vdb-c-mb-16 vdb-c-text-sm vdb-c-text-gray-600 " >
28- A public link to your chat has been created. Manage previously shared
29- chats at any time via Settings.
27+ <p class =" vdb-c-mb-16 vdb-c-text-sm vdb-c-text-black " >
28+ Share the link with everyone to show all the cool things you made
29+ {{ ":)" }}
3030 </p >
3131
3232 <!-- Loading State -->
5151 <input
5252 :value =" publicLink"
5353 readonly
54- class =" vdb-c-flex-1 vdb-c-border-none vdb-c-bg-transparent vdb-c-text-sm vdb-c-text-gray-800 vdb-c-outline-none"
54+ class =" vdb-c-flex-1 vdb-c-border-none vdb-c-bg-transparent vdb-c-text-sm vdb-c-text-black vdb-c-outline-none"
5555 />
5656 <button
5757 @click =" copyLink"
@@ -149,6 +149,10 @@ const props = defineProps({
149149 type: String ,
150150 default: " " ,
151151 },
152+ isPublic: {
153+ type: Boolean ,
154+ default: false ,
155+ },
152156 onMakePublic: {
153157 type: Function ,
154158 required: true ,
@@ -184,7 +188,7 @@ const copyLink = async () => {
184188};
185189
186190const shareOnLinkedIn = () => {
187- const url = ` https://www.linkedin.com/sharing/share-offsite/?url= ${ encodeURIComponent (publicLink .value )} ` ;
191+ const url = ` https://www.linkedin.com/feed/?shareActive=true&text= ${ encodeURIComponent (" Check out this chat session from VideoDB Director! \n " + publicLink .value )} ` ;
188192 window .open (url, " _blank" );
189193};
190194
@@ -198,11 +202,41 @@ const shareOnX = () => {
198202 window .open (url, " _blank" );
199203};
200204
205+ const initializeShare = async (sid ) => {
206+ if (! sid || ! props .showDialog ) return ;
207+ if (props .isPublic ) {
208+ publicLink .value = ` ${ window .location .origin } /share/${ sid} ` ;
209+ isLoading .value = false ;
210+ error .value = " " ;
211+ return ;
212+ }
213+ isLoading .value = true ;
214+ error .value = " " ;
215+ publicLink .value = " " ;
216+ try {
217+ const result = await props .onMakePublic (sid);
218+ if (result .success ) {
219+ publicLink .value = ` ${ window .location .origin } /share/${ sid} ` ;
220+ } else {
221+ error .value = result .error || " Failed to create public link" ;
222+ }
223+ } catch (err) {
224+ error .value = " Failed to create public link" ;
225+ console .error (" Error making session public:" , err);
226+ } finally {
227+ isLoading .value = false ;
228+ }
229+ };
230+
201231// Watch for sessionId changes and make session public
202232watch (
203233 () => props .sessionId ,
204234 async (newSessionId ) => {
205235 if (newSessionId && props .showDialog ) {
236+ if (props .isPublic ) {
237+ publicLink .value = ` ${ window .location .origin } /share/${ newSessionId} ` ;
238+ return ;
239+ }
206240 isLoading .value = true ;
207241 error .value = " " ;
208242 publicLink .value = " " ;
@@ -224,6 +258,16 @@ watch(
224258 },
225259 { immediate: true },
226260);
261+
262+ // Re-run initialization whenever the modal is opened
263+ watch (
264+ () => props .showDialog ,
265+ async (isOpen ) => {
266+ if (isOpen) {
267+ await initializeShare (props .sessionId );
268+ }
269+ },
270+ );
227271 </script >
228272
229273<style scoped>
0 commit comments