}
);
@@ -932,7 +932,7 @@ function DisplayView() {
const [encounterError, setEncounterError] = useState(null);
const [campaignBackgroundUrl, setCampaignBackgroundUrl] = useState('');
const [isPlayerDisplayActive, setIsPlayerDisplayActive] = useState(false);
- const currentTurnRef = useRef(null); // Ref for the current turn participant's element
+ const currentTurnRef = useRef(null);
useEffect(() => {
if (!db) {
@@ -994,7 +994,6 @@ function DisplayView() {
};
}, [activeDisplayData, isLoadingActiveDisplay]);
- // Scroll to current turn participant
useEffect(() => {
if (currentTurnRef.current) {
currentTurnRef.current.scrollIntoView({
@@ -1002,7 +1001,7 @@ function DisplayView() {
block: 'center',
});
}
- }, [activeEncounterData?.currentTurnParticipantId]); // Rerun when current turn changes
+ }, [activeEncounterData?.currentTurnParticipantId]);
if (isLoadingActiveDisplay || (isPlayerDisplayActive && isLoadingEncounter)) {
return
Loading Player Display...
;
@@ -1043,8 +1042,8 @@ function DisplayView() {
}
let participantsToRender = allOrderedActiveParticipants;
- const FOCUSED_VIEW_THRESHOLD = 7;
- const ITEMS_AROUND_CURRENT = 2; // Show 2 before and 2 after current = 5 total in focused view
+ const FOCUSED_VIEW_THRESHOLD = 7; // When to switch to focused view
+ const ITEMS_AROUND_CURRENT = 3; // Show 3 before and 3 after current = 7 total in focused view
let inFocusedView = false;
if (isStarted && allOrderedActiveParticipants.length >= FOCUSED_VIEW_THRESHOLD) {
@@ -1054,12 +1053,12 @@ function DisplayView() {
const focusedList = [];
for (let i = -ITEMS_AROUND_CURRENT; i <= ITEMS_AROUND_CURRENT; i++) {
const listLength = allOrderedActiveParticipants.length;
+ // Ensure the index wraps around correctly for the circular list effect
const actualIndex = (currentIndex + i + listLength) % listLength;
focusedList.push(allOrderedActiveParticipants[actualIndex]);
}
participantsToRender = focusedList;
} else {
- // Fallback if current turn ID not found, show first few (should not happen ideally)
participantsToRender = allOrderedActiveParticipants.slice(0, ITEMS_AROUND_CURRENT * 2 + 1);
}
}
@@ -1087,12 +1086,11 @@ function DisplayView() {
{!isStarted && (!participants || participants.length === 0) &&