Skip to content

Commit

Permalink
fix: add option to show unconfirmed platforms
Browse files Browse the repository at this point in the history
Fixes #174
  • Loading branch information
davwheat committed Apr 4, 2024
1 parent 77a5ce0 commit 757012a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/components/AmeyLiveTrainAnnouncements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
const [selectedCrs, setSelectedCrs] = useState('ECR')
const [hasEnabledFeature, setHasEnabledFeature] = useState(false)
const [useLegacyTocNames, setUseLegacyTocNames] = useStateWithLocalStorage<boolean>('amey.live-trains.use-legacy-toc-names', false)
const [showUnconfirmedPlatforms, setShowUnconfirmedPlatforms] = useStateWithLocalStorage<boolean>(
'amey.live-trains.show-unconfirmed-platforms',
false,
)
const [isPlaying, setIsPlaying] = useState(false)
const [enabledAnnouncements, setEnabledAnnouncements] = useStateWithLocalStorage<AnnouncementType[]>('amey.live-trains.announcement-types', [
AnnouncementType.Next,
Expand Down Expand Up @@ -815,7 +819,8 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
try {
const resp = await fetch(
process.env.NODE_ENV === 'development'
? `http://localhost:8787/get-services?${params}`
? // ? `http://localhost:8787/get-services?${params}`
`http://localhost:34143/get-services?${params}`
: `https://api.railannouncements.co.uk/get-services?${params}`,
)

Expand Down Expand Up @@ -1068,6 +1073,10 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
iframeQueryParams.append('useLegacyTocNames', '1')
}

if (showUnconfirmedPlatforms) {
iframeQueryParams.append('showUnconfirmedPlatforms', '1')
}

Object.entries(systemKeyForPlatform)
.filter(([_, system]) => system !== null)
.forEach(([p]) => {
Expand Down Expand Up @@ -1418,6 +1427,21 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
</details>
</fieldset>

<label htmlFor="show-unconfirmed-platforms">
<input
type="checkbox"
name="show-unconfirmed-platforms"
id="show-unconfirmed-platforms"
aria-describedby="help-show-unconfirmed-platforms"
checked={showUnconfirmedPlatforms}
onChange={e => setShowUnconfirmedPlatforms(e.target.checked)}
/>
Show trains with unconfirmed platforms
</label>
<p id="help-show-unconfirmed-platforms" style={{ fontSize: '0.8em', marginLeft: 40, marginTop: -8 }}>
Useful for stations where platforms are suppressed from live data feeds, such as King's Cross.
</p>

<p style={{ margin: '16px 0' }}>
This is a beta feature, and isn't complete or fully functional. Please report any issues you face{' '}
<a href="https://github.com/davwheat/rail-announcements/issues">on GitHub</a>.
Expand Down

0 comments on commit 757012a

Please sign in to comment.