From 18da11c3eadf136c0a98ee5a2ef5beffec94838e Mon Sep 17 00:00:00 2001 From: bedlam343 Date: Wed, 22 May 2024 17:13:22 -0700 Subject: [PATCH] fix highlighting elements in list on gaze --- src/components/Widget/HistoryWidget.tsx | 10 ++++-- src/components/Widget/ListWidget.tsx | 46 +++++++++++++++++-------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/components/Widget/HistoryWidget.tsx b/src/components/Widget/HistoryWidget.tsx index 1d34c1f..8bd6f53 100644 --- a/src/components/Widget/HistoryWidget.tsx +++ b/src/components/Widget/HistoryWidget.tsx @@ -7,7 +7,7 @@ import { } from 'src/redux/slices/componentSlice'; import { useAppSelector } from 'src/redux/hooks'; import { getMessages } from 'src/redux/slices/minimapSlice'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; type HistoryWidgetProps = { widget: HistoryWidgetType; @@ -22,7 +22,13 @@ const HistoryWidget = ({ widget }: HistoryWidgetProps) => { ); const activeElementID = useAppSelector(getSelectedElementID); - const highlightIndex = convoMessages.findIndex((message) => message.id === activeElementID) + useEffect(() => { + console.log('activeElementID: ', activeElementID); + }, [activeElementID]); + + const highlightIndex = convoMessages.findIndex( + (message) => message.id === activeElementID, + ); return (
{ + const elementsInGaze = useAppSelector(getElementsInGaze); + + // just pick the first element in the gaze for now + const elementInGazeId = elementsInGaze[0]?.id; + + // useEffect(() => { + // console.log('elementsInGaze: ', elementsInGaze); + // }, [elementsInGaze]); + const className = 'absolute p-2 flex flex-col gap-6 items-center overflow-scroll overflow-x-hidden overflow-y-hidden'; @@ -21,16 +35,18 @@ const ListWidget = ({ widget }: ListWidgetProps) => { const dispatch = useAppDispatch(); - useEffect(() => { - dispatch( - setActiveConvoID( - sortedElementsByPriority[selectedElement].message?.conversationId ?? '', - ), - dispatch( - setSelectedElementID(sortedElementsByPriority[selectedElement].message?.id) - ) - ); - }, [selectedElement]); + // useEffect(() => { + // dispatch( + // setActiveConvoID( + // sortedElementsByPriority[selectedElement].message?.conversationId ?? '', + // ), + // dispatch( + // setSelectedElementID( + // sortedElementsByPriority[selectedElement].message?.id, + // ), + // ), + // ); + // }, [selectedElement]); return (
{ left: widget.x, }} > - {sortedElementsByPriority.map((element, index) => { + {sortedElementsByPriority.map((element) => { const style = - selectedElement === index + element.id === elementInGazeId ? 'bg-[#444449] text-[28px] font-medium' : 'bg-[#323235] text-[24px]'; + return ( // ListWidget enforces a certain layout and style for its Elements
{ key={element.id} style={{ height: 80 }} className={`w-full text-white flex items-center justify-center rounded-xl p-3 ${style}`} - onMouseEnter={() => setSelectedElement(index)} // temporary test > {/* Nested children here if wanted.. */}