Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/chat/ChatInterface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
<ShareModal
:show-dialog="showShareModal"
:session-id="sessionToShare?.session_id"
:is-public="sessionToShare?.is_public"
:on-make-public="makeSessionPublic"
@close="showShareModal = false"
/>
Expand Down
8 changes: 8 additions & 0 deletions src/components/hooks/useVideoDBAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ export function useVideoDBAgent(config) {
res.status = "success";
res.success = true;
res.data = data;

const idx = sessions.value.findIndex((s) => s.session_id === sessionId);
if (idx !== -1) {
sessions.value[idx] = {
...sessions.value[idx],
is_public: isPublic,
};
}
} catch (error) {
res.status = "error";
res.success = false;
Expand Down
54 changes: 49 additions & 5 deletions src/components/modals/ShareModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
</div>

<!-- Description -->
<p class="vdb-c-mb-16 vdb-c-text-sm vdb-c-text-gray-600">
A public link to your chat has been created. Manage previously shared
chats at any time via Settings.
<p class="vdb-c-mb-16 vdb-c-text-sm vdb-c-text-black">
Share the link with everyone to show all the cool things you made
{{ ":)" }}
</p>

<!-- Loading State -->
Expand All @@ -51,7 +51,7 @@
<input
:value="publicLink"
readonly
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"
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"
/>
<button
@click="copyLink"
Expand Down Expand Up @@ -149,6 +149,10 @@ const props = defineProps({
type: String,
default: "",
},
isPublic: {
type: Boolean,
default: false,
},
onMakePublic: {
type: Function,
required: true,
Expand Down Expand Up @@ -184,7 +188,7 @@ const copyLink = async () => {
};

const shareOnLinkedIn = () => {
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(publicLink.value)}`;
const url = `https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent("Check out this chat session from VideoDB Director! \n" + publicLink.value)}`;
window.open(url, "_blank");
};

Expand All @@ -198,11 +202,41 @@ const shareOnX = () => {
window.open(url, "_blank");
};

const initializeShare = async (sid) => {
if (!sid || !props.showDialog) return;
if (props.isPublic) {
publicLink.value = `${window.location.origin}/share/${sid}`;
isLoading.value = false;
error.value = "";
return;
}
isLoading.value = true;
error.value = "";
publicLink.value = "";
try {
const result = await props.onMakePublic(sid);
if (result.success) {
publicLink.value = `${window.location.origin}/share/${sid}`;
} else {
error.value = result.error || "Failed to create public link";
}
} catch (err) {
error.value = "Failed to create public link";
console.error("Error making session public:", err);
} finally {
isLoading.value = false;
}
};

// Watch for sessionId changes and make session public
watch(
() => props.sessionId,
async (newSessionId) => {
if (newSessionId && props.showDialog) {
if (props.isPublic) {
publicLink.value = `${window.location.origin}/share/${newSessionId}`;
return;
}
isLoading.value = true;
error.value = "";
publicLink.value = "";
Expand All @@ -224,6 +258,16 @@ watch(
},
{ immediate: true },
);

// Re-run initialization whenever the modal is opened
watch(
() => props.showDialog,
async (isOpen) => {
if (isOpen) {
await initializeShare(props.sessionId);
}
},
);
</script>

<style scoped>
Expand Down