@@ -20,6 +20,8 @@ import {
2020 saveFloatingState ,
2121 clearFloatingState ,
2222 getDefaultFloatingPosition ,
23+ loadMinimizedState ,
24+ saveMinimizedState ,
2325} from "../../lib/floatingChats" ;
2426
2527// Context for sharing editor-level data with chat blocks
@@ -42,7 +44,6 @@ interface ChatBlockProps {
4244 props : {
4345 chatId : string ;
4446 title : string ;
45- minimized : boolean ;
4647 height : number ;
4748 width : number ;
4849 } ;
@@ -52,7 +53,10 @@ interface ChatBlockProps {
5253export function ChatBlock ( { block } : ChatBlockProps ) {
5354 const context = useContext ( EditorContext ) ;
5455 const editor = useBlockNoteEditor ( ) ;
55- const [ isMinimized , setIsMinimized ] = useState ( block . props . minimized ) ;
56+ const chatId = block . props . chatId ;
57+
58+ // Load minimized state from localStorage (local to each user)
59+ const [ isMinimized , setIsMinimized ] = useState ( ( ) => loadMinimizedState ( chatId ) ) ;
5660 const [ height , setHeight ] = useState ( block . props . height || 400 ) ;
5761 const [ width , setWidth ] = useState ( block . props . width || 600 ) ;
5862 const [ isResizing , setIsResizing ] = useState ( false ) ;
@@ -89,7 +93,6 @@ export function ChatBlock({ block }: ChatBlockProps) {
8993 }
9094
9195 const { doc, channel, userId, userName, userColor, presenceUsers } = context ;
92- const chatId = block . props . chatId ;
9396
9497 // Use all chat hooks
9598 const { messages, sendMessage, addReaction } = useChat (
@@ -124,11 +127,6 @@ export function ChatBlock({ block }: ChatBlockProps) {
124127 }
125128 } , [ chatId ] ) ;
126129
127- // Sync minimized state from block props
128- useEffect ( ( ) => {
129- setIsMinimized ( block . props . minimized ) ;
130- } , [ block . props . minimized ] ) ;
131-
132130 // Toggle floating handler
133131 const handleToggleFloating = useCallback ( ( ) => {
134132 if ( isFloating ) {
@@ -524,12 +522,8 @@ export function ChatBlock({ block }: ChatBlockProps) {
524522 const newMinimizedState = ! isMinimized ;
525523 setIsMinimized ( newMinimizedState ) ;
526524
527- // Persist minimized state to block props
528- if ( editor ) {
529- editor . updateBlock ( block . id , {
530- props : { ...block . props , minimized : newMinimizedState } ,
531- } ) ;
532- }
525+ // Persist minimized state to localStorage (local, not synced)
526+ saveMinimizedState ( chatId , newMinimizedState ) ;
533527 } }
534528 style = { {
535529 width : "24px" ,
0 commit comments