Skip to content

Commit

Permalink
[desk-tool] Fix selection state
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr authored and rexxars committed Oct 6, 2020
1 parent 1900fd4 commit f0db797
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function DocumentPane(props: Props) {
onSelect={time => toggleHistory(time)}
displayed={historyDisplayed}
onSelectDisplayed={toggleHistoryDisplayed}
startTimeId={startTimeId}
startTime={startTime}
/>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,30 @@ interface HistoryTimelinePanelProps {
timeline: Timeline
onSelect: (id: string) => void
displayed: 'from' | 'to'
startTimeId?: string
endTimeId?: string
startTime: TimeRef | null
}

export function HistoryTimelinePanel(props: HistoryTimelinePanelProps) {
const {timeline, onSelect, displayed} = props

// @todo
let isFirst = true
let isSelected = true
let isSelected = false

return (
<div className={styles.root}>
<div className={styles.header}>Timeline</div>

{timeline.mapChunks((chunk, idx) => {
const timeId = timeline.createTimeId(idx, chunk)
const isStartTime = props.startTimeId === timeId
const isEndTime = isFirst && !props.endTimeId ? true : props.endTimeId === timeId
const isStartTime = props.startTime && props.startTime.chunk === chunk
const isEndTime = props.startTime && isFirst
console.log({isStartTime, isEndTime})

isFirst = false

if (isStartTime) {
isSelected = false
if (isEndTime) {
isSelected = true
}

return (
const item = (
<div
className={styles.item}
data-selected={isSelected}
Expand All @@ -44,13 +41,21 @@ export function HistoryTimelinePanel(props: HistoryTimelinePanelProps) {
onClick={evt => {
evt.preventDefault()
evt.stopPropagation()
onSelect(timeId)
onSelect(timeline.createTimeId(idx, chunk))
}}
>
<div className={styles.item__typeName}>{chunk.type}</div>
<div className={styles.item__timestamp}>{format(chunk.startTimestamp)}</div>
</div>
)

if (isStartTime) {
isSelected = false
}

isFirst = false

return item
})}
</div>
)
Expand Down

0 comments on commit f0db797

Please sign in to comment.