Skip to content

Commit e11b92f

Browse files
authored
Merge pull request #89 from opentripplanner/stop-viewer-fixes
Remove star, fix tz issue, and fix index.html
2 parents 79a865c + 4d432b0 commit e11b92f

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

Diff for: index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
</head>
1010
<body>
1111
<div id="root"></div>
12-
<script src="dist/index.js"></script>
12+
<!--
13+
Only one of the following js files is needed. For development
14+
use example.js. For production use dist/index.js.
15+
-->
16+
<!-- <script src="dist/index.js"></script> -->
17+
<script src="/example.js"></script>
1318
</body>
1419
</html>

Diff for: lib/components/viewers/stop-viewer.js

+24-13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { setMainPanelContent, toggleAutoRefresh } from '../../actions/ui'
1313
import { findStop, findStopTimesForStop } from '../../actions/api'
1414
import { forgetStop, rememberStop, setLocation } from '../../actions/map'
1515
import { routeComparator } from '../../util/itinerary'
16+
import { getShowUserSettings } from '../../util/state'
1617
import { formatDuration, formatStopTime, getTimeFormat } from '../../util/time'
1718

1819
class StopViewer extends Component {
@@ -110,9 +111,10 @@ class StopViewer extends Component {
110111

111112
render () {
112113
const {
113-
stopData,
114114
hideBackButton,
115115
homeTimezone,
116+
showUserSettings,
117+
stopData,
116118
stopViewerArriving,
117119
timeFormat
118120
} = this.props
@@ -166,17 +168,20 @@ class StopViewer extends Component {
166168
? <span>{stopData.name}</span>
167169
: <span>Loading Stop...</span>
168170
}
169-
<Button
170-
onClick={this._toggleFavorite}
171-
bsSize='large'
172-
style={{
173-
color: this._isFavorite() ? 'yellow' : 'black',
174-
padding: 0,
175-
marginLeft: '5px'
176-
}}
177-
bsStyle='link'>
178-
<Icon type={this._isFavorite() ? 'star' : 'star-o'} />
179-
</Button>
171+
{showUserSettings
172+
? <Button
173+
onClick={this._toggleFavorite}
174+
bsSize='large'
175+
style={{
176+
color: this._isFavorite() ? 'yellow' : 'black',
177+
padding: 0,
178+
marginLeft: '5px'
179+
}}
180+
bsStyle='link'>
181+
<Icon type={this._isFavorite() ? 'star' : 'star-o'} />
182+
</Button>
183+
: null
184+
}
180185
</div>
181186
<div style={{ clear: 'both' }} />
182187
</div>
@@ -376,7 +381,11 @@ class PatternRow extends Component {
376381

377382
const ONE_HOUR_IN_SECONDS = 3600
378383

379-
function getHomeTime (homeTimezone) {
384+
/**
385+
* @param {string} [homeTimezone='America/New_York'] Timezone string
386+
* @return {number} Current time in home timezone in seconds since midnight
387+
*/
388+
function getHomeTime (homeTimezone = 'America/New_York') {
380389
const now = moment()
381390
return now.tz(homeTimezone).diff(now.clone().startOf('day'), 'seconds')
382391
}
@@ -475,11 +484,13 @@ function getStatusLabel (delay) {
475484
// connect to redux store
476485

477486
const mapStateToProps = (state, ownProps) => {
487+
const showUserSettings = getShowUserSettings(state.otp)
478488
return {
479489
autoRefreshStopTimes: state.otp.user.autoRefreshStopTimes,
480490
favoriteStops: state.otp.user.favoriteStops,
481491
homeTimezone: state.otp.config.homeTimezone,
482492
viewedStop: state.otp.ui.viewedStop,
493+
showUserSettings,
483494
stopData: state.otp.transitIndex.stops[state.otp.ui.viewedStop.stopId],
484495
stopViewerArriving: state.otp.config.language.stopViewerArriving,
485496
timeFormat: getTimeFormat(state.otp.config)

0 commit comments

Comments
 (0)