diff --git a/apps/react/comments/dashboard/custom/dashboard-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/dashboard/custom/dashboard-demo/components/velt/VeltCollaboration.tsx index 0e56a21..5d40c98 100644 --- a/apps/react/comments/dashboard/custom/dashboard-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/dashboard/custom/dashboard-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/dashboard/inline-comments/dashboard-inline-comments-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/dashboard/inline-comments/dashboard-inline-comments-demo/components/velt/VeltCollaboration.tsx index 4db7f0c..9db47c0 100644 --- a/apps/react/comments/dashboard/inline-comments/dashboard-inline-comments-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/dashboard/inline-comments/dashboard-inline-comments-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demo/components/velt/VeltCollaboration.tsx index 09c83e1..f0e2c2a 100644 --- a/apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demo/components/velt/VeltCollaboration.tsx @@ -1,7 +1,7 @@ "use client"; import { useAppUser } from "@/app/userAuth/AppUserContext"; import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; import { useSelectedJob } from "@/app/document/JobsContext"; @@ -10,9 +10,18 @@ export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); const selectedJob = useSelectedJob(); + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); + // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { if (isUserLoggedIn === false && client) { diff --git a/apps/react/comments/dashboard/self-hosting/dashboard-postgres-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/dashboard/self-hosting/dashboard-postgres-demo/components/velt/VeltCollaboration.tsx index 09c83e1..f0e2c2a 100644 --- a/apps/react/comments/dashboard/self-hosting/dashboard-postgres-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/dashboard/self-hosting/dashboard-postgres-demo/components/velt/VeltCollaboration.tsx @@ -1,7 +1,7 @@ "use client"; import { useAppUser } from "@/app/userAuth/AppUserContext"; import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; import { useSelectedJob } from "@/app/document/JobsContext"; @@ -10,9 +10,18 @@ export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); const selectedJob = useSelectedJob(); + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); + // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { if (isUserLoggedIn === false && client) { diff --git a/apps/react/comments/tables/ag-grid/comment-aggregation/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/ag-grid/comment-aggregation/components/velt/VeltCollaboration.tsx index a970ef6..2df9315 100644 --- a/apps/react/comments/tables/ag-grid/comment-aggregation/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/ag-grid/comment-aggregation/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/tables/ag-grid/multiple-tools/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/ag-grid/multiple-tools/components/velt/VeltCollaboration.tsx index f72bbca..d2a5239 100644 --- a/apps/react/comments/tables/ag-grid/multiple-tools/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/ag-grid/multiple-tools/components/velt/VeltCollaboration.tsx @@ -2,12 +2,21 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/tables/ag-grid/single-tool/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/ag-grid/single-tool/components/velt/VeltCollaboration.tsx index a59f526..105c778 100644 --- a/apps/react/comments/tables/ag-grid/single-tool/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/ag-grid/single-tool/components/velt/VeltCollaboration.tsx @@ -2,12 +2,21 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/tables/tanstack/comment-aggregation/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/tanstack/comment-aggregation/components/velt/VeltCollaboration.tsx index a970ef6..2df9315 100644 --- a/apps/react/comments/tables/tanstack/comment-aggregation/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/tanstack/comment-aggregation/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/tables/tanstack/multiple-tools/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/tanstack/multiple-tools/components/velt/VeltCollaboration.tsx index 9ec7c46..5fb0e9e 100644 --- a/apps/react/comments/tables/tanstack/multiple-tools/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/tanstack/multiple-tools/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/tables/tanstack/single-tool/components/velt/VeltCollaboration.tsx b/apps/react/comments/tables/tanstack/single-tool/components/velt/VeltCollaboration.tsx index a59f526..105c778 100644 --- a/apps/react/comments/tables/tanstack/single-tool/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/tables/tanstack/single-tool/components/velt/VeltCollaboration.tsx @@ -2,12 +2,21 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/text-editors/lexical/lexical-comments-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/text-editors/lexical/lexical-comments-demo/components/velt/VeltCollaboration.tsx index 728b9b7..1e69e87 100644 --- a/apps/react/comments/text-editors/lexical/lexical-comments-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/text-editors/lexical/lexical-comments-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/text-editors/slatejs/slatejs-comments-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/text-editors/slatejs/slatejs-comments-demo/components/velt/VeltCollaboration.tsx index 728b9b7..1e69e87 100644 --- a/apps/react/comments/text-editors/slatejs/slatejs-comments-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/text-editors/slatejs/slatejs-comments-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/comments/text-editors/tiptap/tiptap-comments-demo/components/velt/VeltCollaboration.tsx b/apps/react/comments/text-editors/tiptap/tiptap-comments-demo/components/velt/VeltCollaboration.tsx index 728b9b7..1e69e87 100644 --- a/apps/react/comments/text-editors/tiptap/tiptap-comments-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/comments/text-editors/tiptap/tiptap-comments-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/crdt/canvas/reactflow/reactflow-demo/components/velt/VeltCollaboration.tsx b/apps/react/crdt/canvas/reactflow/reactflow-demo/components/velt/VeltCollaboration.tsx index f06c1f1..ed2a014 100644 --- a/apps/react/crdt/canvas/reactflow/reactflow-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/crdt/canvas/reactflow/reactflow-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltCursor, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/crdt/text-editors/blocknote/blocknote-demo/components/velt/VeltCollaboration.tsx b/apps/react/crdt/text-editors/blocknote/blocknote-demo/components/velt/VeltCollaboration.tsx index f06c1f1..ed2a014 100644 --- a/apps/react/crdt/text-editors/blocknote/blocknote-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/crdt/text-editors/blocknote/blocknote-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltCursor, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/crdt/text-editors/codemirror/codemirror-crdt-demo/components/velt/VeltCollaboration.tsx b/apps/react/crdt/text-editors/codemirror/codemirror-crdt-demo/components/velt/VeltCollaboration.tsx index 728b9b7..1e69e87 100644 --- a/apps/react/crdt/text-editors/codemirror/codemirror-crdt-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/crdt/text-editors/codemirror/codemirror-crdt-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => { diff --git a/apps/react/crdt/text-editors/tiptap/tiptap-crdt-demo/components/velt/VeltCollaboration.tsx b/apps/react/crdt/text-editors/tiptap/tiptap-crdt-demo/components/velt/VeltCollaboration.tsx index 3b53118..0a5e96a 100644 --- a/apps/react/crdt/text-editors/tiptap/tiptap-crdt-demo/components/velt/VeltCollaboration.tsx +++ b/apps/react/crdt/text-editors/tiptap/tiptap-crdt-demo/components/velt/VeltCollaboration.tsx @@ -2,13 +2,22 @@ import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react"; import VeltInitializeDocument from "./VeltInitializeDocument"; import { VeltCustomization } from "./ui-customization/VeltCustomization"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useAppUser } from "@/app/userAuth/AppUserContext"; export function VeltCollaboration() { const { isUserLoggedIn } = useAppUser(); // [Velt] Get Velt client instance const { client } = useVeltClient(); + const hasSignedOutOnMount = useRef(false); + + // [Velt] Sign out any previous user on mount to clear stale state + useEffect(() => { + if (!hasSignedOutOnMount.current && client) { + hasSignedOutOnMount.current = true; + client.signOutUser(); + } + }, [client]); // [Velt] Sign out user when user logs out, getting user login state from host app useEffect(() => {