@@ -15,7 +15,7 @@ interface IStoryViewerPanelProps {
1515}
1616
1717function StoryViewerPanel ( { model, togglePreview } : IStoryViewerPanelProps ) {
18- const [ currentRankDisplayed , setCurrentRankDisplayed ] = useState ( 0 ) ;
18+ const [ currentIndexDisplayed , setCurrentIndexDisplayed ] = useState ( 0 ) ;
1919 const [ storyData , setStoryData ] = useState < IJGISStoryMap | null > ( null ) ;
2020
2121 // Derive landmarks from story data
@@ -29,10 +29,10 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
2929 . filter ( ( layer ) : layer is IJGISLayer => layer !== undefined ) ;
3030 } , [ storyData , model ] ) ;
3131
32- // Derive current landmark from landmarks and currentRankDisplayed
32+ // Derive current landmark from landmarks and currentIndexDisplayed
3333 const currentLandmark = useMemo ( ( ) => {
34- return landmarks [ currentRankDisplayed ] ;
35- } , [ landmarks , currentRankDisplayed ] ) ;
34+ return landmarks [ currentIndexDisplayed ] ;
35+ } , [ landmarks , currentIndexDisplayed ] ) ;
3636
3737 // Derive active slide and layer name from current landmark
3838 const activeSlide = useMemo ( ( ) => {
@@ -45,15 +45,15 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
4545
4646 // Derive landmark ID for zooming
4747 const currentLandmarkId = useMemo ( ( ) => {
48- return storyData ?. landmarks ?. [ currentRankDisplayed ] ;
49- } , [ storyData , currentRankDisplayed ] ) ;
48+ return storyData ?. landmarks ?. [ currentIndexDisplayed ] ;
49+ } , [ storyData , currentIndexDisplayed ] ) ;
5050
5151 useEffect ( ( ) => {
5252 const updateStory = ( ) => {
5353 const { story } = model . getSelectedStory ( ) ;
5454 setStoryData ( story ?? null ) ;
5555 // Reset to first slide when story changes
56- setCurrentRankDisplayed ( 0 ) ;
56+ setCurrentIndexDisplayed ( 0 ) ;
5757 } ;
5858
5959 updateStory ( ) ;
@@ -73,11 +73,11 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
7373 } , [ currentLandmarkId , model ] ) ;
7474
7575 // Listen for layer selection changes in unguided mode
76- // ! TODO refactor selection stuff
7776 useEffect ( ( ) => {
78- const handleAwarenessChange = ( thig : any , more : any , extra : any ) => {
77+ // ! TODO this logic (getting a single selected layer) is also in the processing index.ts, move to tools
78+ const handleSelectedLandmarkChange = ( thig : any , more : any , extra : any ) => {
7979 // This is just to update the displayed content
80- // So bail early if we don't need to do thath
80+ // So bail early if we don't need to do that
8181 if ( ! storyData || storyData . storyType !== 'unguided' ) {
8282 return ;
8383 }
@@ -105,13 +105,13 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
105105 return ;
106106 }
107107
108- setCurrentRankDisplayed ( index ) ;
108+ setCurrentIndexDisplayed ( index ) ;
109109 } ;
110110
111- model . sharedModel . awareness . on ( 'change' , handleAwarenessChange ) ;
111+ model . sharedModel . awareness . on ( 'change' , handleSelectedLandmarkChange ) ;
112112
113113 return ( ) => {
114- model . sharedModel . awareness . off ( 'change' , handleAwarenessChange ) ;
114+ model . sharedModel . awareness . off ( 'change' , handleSelectedLandmarkChange ) ;
115115 } ;
116116 } , [ model , storyData ] ) ;
117117
@@ -122,14 +122,14 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
122122 } ;
123123
124124 const handlePrev = ( ) => {
125- if ( currentRankDisplayed > 0 ) {
126- setCurrentRankDisplayed ( currentRankDisplayed - 1 ) ;
125+ if ( currentIndexDisplayed > 0 ) {
126+ setCurrentIndexDisplayed ( currentIndexDisplayed - 1 ) ;
127127 }
128128 } ;
129129
130130 const handleNext = ( ) => {
131- if ( currentRankDisplayed < landmarks . length - 1 ) {
132- setCurrentRankDisplayed ( currentRankDisplayed + 1 ) ;
131+ if ( currentIndexDisplayed < landmarks . length - 1 ) {
132+ setCurrentIndexDisplayed ( currentIndexDisplayed + 1 ) ;
133133 }
134134 } ;
135135
@@ -175,7 +175,7 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
175175 textAlign : 'center' ,
176176 } }
177177 >
178- { `Slide ${ currentRankDisplayed + 1 } - ${ layerName ? layerName : 'Landmark Name' } ` }
178+ { `Slide ${ currentIndexDisplayed + 1 } - ${ layerName ? layerName : 'Landmark Name' } ` }
179179 </ h1 >
180180 </ div >
181181 ) : (
@@ -186,11 +186,6 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
186186 ? activeSlide . content . title
187187 : 'Slide Title' }
188188 </ h2 >
189- { /* <h3 style={{ paddingLeft: 2 }}>
190- {activeSlide?.content?.title
191- ? activeSlide.content.title
192- : 'Slide Title'}
193- </h3> */ }
194189 { activeSlide ?. content ?. markdown && (
195190 < div className = "jgis-story-viewer-content" style = { { paddingLeft : 16 } } >
196191 < Markdown > { activeSlide . content . markdown } </ Markdown >
@@ -201,8 +196,8 @@ function StoryViewerPanel({ model, togglePreview }: IStoryViewerPanelProps) {
201196 < StoryNavBar
202197 onPrev = { handlePrev }
203198 onNext = { handleNext }
204- hasPrev = { currentRankDisplayed > 0 }
205- hasNext = { currentRankDisplayed < landmarks . length - 1 }
199+ hasPrev = { currentIndexDisplayed > 0 }
200+ hasNext = { currentIndexDisplayed < landmarks . length - 1 }
206201 />
207202 ) }
208203 < Button onClick = { togglePreview } > Edit Story</ Button >
0 commit comments