File tree Expand file tree Collapse file tree 17 files changed +170
-17
lines changed
canvas/reactflow/reactflow-demo/components/velt
blocknote/blocknote-demo/components/velt
codemirror/codemirror-crdt-demo/components/velt
tiptap/tiptap-crdt-demo/components/velt Expand file tree Collapse file tree 17 files changed +170
-17
lines changed Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 // [Velt] Get Velt client instance
1111 const { client } = useVeltClient ( ) ;
12+ const hasSignedOutOnMount = useRef ( false ) ;
13+
14+ // [Velt] Sign out any previous user on mount to clear stale state
15+ useEffect ( ( ) => {
16+ if ( ! hasSignedOutOnMount . current && client ) {
17+ hasSignedOutOnMount . current = true ;
18+ client . signOutUser ( ) ;
19+ }
20+ } , [ client ] ) ;
1221
1322 // [Velt] Sign out user when user logs out, getting user login state from host app
1423 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 // [Velt] Get Velt client instance
1111 const { client } = useVeltClient ( ) ;
12+ const hasSignedOutOnMount = useRef ( false ) ;
13+
14+ // [Velt] Sign out any previous user on mount to clear stale state
15+ useEffect ( ( ) => {
16+ if ( ! hasSignedOutOnMount . current && client ) {
17+ hasSignedOutOnMount . current = true ;
18+ client . signOutUser ( ) ;
19+ }
20+ } , [ client ] ) ;
1221
1322 // [Velt] Sign out user when user logs out, getting user login state from host app
1423 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 11"use client" ;
22import { useAppUser } from "@/app/userAuth/AppUserContext" ;
33import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
4- import { useEffect } from "react" ;
4+ import { useEffect , useRef } from "react" ;
55import VeltInitializeDocument from "./VeltInitializeDocument" ;
66import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
77import { useSelectedJob } from "@/app/document/JobsContext" ;
@@ -10,9 +10,18 @@ export function VeltCollaboration() {
1010 const { isUserLoggedIn } = useAppUser ( ) ;
1111 // [Velt] Get Velt client instance
1212 const { client } = useVeltClient ( ) ;
13+ const hasSignedOutOnMount = useRef ( false ) ;
1314
1415 const selectedJob = useSelectedJob ( ) ;
1516
17+ // [Velt] Sign out any previous user on mount to clear stale state
18+ useEffect ( ( ) => {
19+ if ( ! hasSignedOutOnMount . current && client ) {
20+ hasSignedOutOnMount . current = true ;
21+ client . signOutUser ( ) ;
22+ }
23+ } , [ client ] ) ;
24+
1625 // [Velt] Sign out user when user logs out, getting user login state from host app
1726 useEffect ( ( ) => {
1827 if ( isUserLoggedIn === false && client ) {
Original file line number Diff line number Diff line change 11"use client" ;
22import { useAppUser } from "@/app/userAuth/AppUserContext" ;
33import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
4- import { useEffect } from "react" ;
4+ import { useEffect , useRef } from "react" ;
55import VeltInitializeDocument from "./VeltInitializeDocument" ;
66import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
77import { useSelectedJob } from "@/app/document/JobsContext" ;
@@ -10,9 +10,18 @@ export function VeltCollaboration() {
1010 const { isUserLoggedIn } = useAppUser ( ) ;
1111 // [Velt] Get Velt client instance
1212 const { client } = useVeltClient ( ) ;
13+ const hasSignedOutOnMount = useRef ( false ) ;
1314
1415 const selectedJob = useSelectedJob ( ) ;
1516
17+ // [Velt] Sign out any previous user on mount to clear stale state
18+ useEffect ( ( ) => {
19+ if ( ! hasSignedOutOnMount . current && client ) {
20+ hasSignedOutOnMount . current = true ;
21+ client . signOutUser ( ) ;
22+ }
23+ } , [ client ] ) ;
24+
1625 // [Velt] Sign out user when user logs out, getting user login state from host app
1726 useEffect ( ( ) => {
1827 if ( isUserLoggedIn === false && client ) {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 // [Velt] Get Velt client instance
1111 const { client } = useVeltClient ( ) ;
12+ const hasSignedOutOnMount = useRef ( false ) ;
13+
14+ // [Velt] Sign out any previous user on mount to clear stale state
15+ useEffect ( ( ) => {
16+ if ( ! hasSignedOutOnMount . current && client ) {
17+ hasSignedOutOnMount . current = true ;
18+ client . signOutUser ( ) ;
19+ }
20+ } , [ client ] ) ;
1221
1322 // [Velt] Sign out user when user logs out, getting user login state from host app
1423 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 const { client } = useVeltClient ( ) ;
11+ const hasSignedOutOnMount = useRef ( false ) ;
12+
13+ // [Velt] Sign out any previous user on mount to clear stale state
14+ useEffect ( ( ) => {
15+ if ( ! hasSignedOutOnMount . current && client ) {
16+ hasSignedOutOnMount . current = true ;
17+ client . signOutUser ( ) ;
18+ }
19+ } , [ client ] ) ;
1120
1221 // [Velt] Sign out user when user logs out, getting user login state from host app
1322 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 const { client } = useVeltClient ( ) ;
11+ const hasSignedOutOnMount = useRef ( false ) ;
12+
13+ // [Velt] Sign out any previous user on mount to clear stale state
14+ useEffect ( ( ) => {
15+ if ( ! hasSignedOutOnMount . current && client ) {
16+ hasSignedOutOnMount . current = true ;
17+ client . signOutUser ( ) ;
18+ }
19+ } , [ client ] ) ;
1120
1221 // [Velt] Sign out user when user logs out, getting user login state from host app
1322 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 // [Velt] Get Velt client instance
1111 const { client } = useVeltClient ( ) ;
12+ const hasSignedOutOnMount = useRef ( false ) ;
13+
14+ // [Velt] Sign out any previous user on mount to clear stale state
15+ useEffect ( ( ) => {
16+ if ( ! hasSignedOutOnMount . current && client ) {
17+ hasSignedOutOnMount . current = true ;
18+ client . signOutUser ( ) ;
19+ }
20+ } , [ client ] ) ;
1221
1322 // [Velt] Sign out user when user logs out, getting user login state from host app
1423 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 // [Velt] Get Velt client instance
1111 const { client } = useVeltClient ( ) ;
12+ const hasSignedOutOnMount = useRef ( false ) ;
13+
14+ // [Velt] Sign out any previous user on mount to clear stale state
15+ useEffect ( ( ) => {
16+ if ( ! hasSignedOutOnMount . current && client ) {
17+ hasSignedOutOnMount . current = true ;
18+ client . signOutUser ( ) ;
19+ }
20+ } , [ client ] ) ;
1221
1322 // [Velt] Sign out user when user logs out, getting user login state from host app
1423 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 22import { useVeltClient , VeltComments , VeltCommentsSidebar } from "@veltdev/react" ;
33import VeltInitializeDocument from "./VeltInitializeDocument" ;
44import { VeltCustomization } from "./ui-customization/VeltCustomization" ;
5- import { useEffect } from "react" ;
5+ import { useEffect , useRef } from "react" ;
66import { useAppUser } from "@/app/userAuth/AppUserContext" ;
77
88export function VeltCollaboration ( ) {
99 const { isUserLoggedIn } = useAppUser ( ) ;
1010 const { client } = useVeltClient ( ) ;
11+ const hasSignedOutOnMount = useRef ( false ) ;
12+
13+ // [Velt] Sign out any previous user on mount to clear stale state
14+ useEffect ( ( ) => {
15+ if ( ! hasSignedOutOnMount . current && client ) {
16+ hasSignedOutOnMount . current = true ;
17+ client . signOutUser ( ) ;
18+ }
19+ } , [ client ] ) ;
1120
1221 // [Velt] Sign out user when user logs out, getting user login state from host app
1322 useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments