Skip to content

Commit

Permalink
fix: some small things (#1860)
Browse files Browse the repository at this point in the history
* fix(EventController): use better default value

* fix: Run compile.assets commands in better order

* fix: use optional chaining operator

* fix(StopMap): don't request map tiles without config

* fix(Mixfile): add revised comment
  • Loading branch information
thecristen authored Jan 23, 2024
1 parent e1feec4 commit 0573659
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/js/cr-timetable-train-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class CRTimetableTrainIcons {
return stop;
}
// For vehicles in transit with prior stop data, put the vehicle in the prior stop container
const stopSequence = this.schedules[stop].stop_sequence || 1;
const stopSequence = this.schedules[stop]?.stop_sequence || 1;
return this.priorStops[`${vehicle.trip_id}-${stopSequence - 1}`];
}
}
6 changes: 2 additions & 4 deletions assets/js/cr-timetable-trains.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ export class CRTimetableTrains {
}

onVehicles(ev) {
const { data } = ev.detail;
data.forEach(vehicle => this.icons.addOrUpdateTrain(vehicle));
ev.detail?.data?.forEach(vehicle => this.icons.addOrUpdateTrain(vehicle));
}

onRemoveVehicles(ev) {
const { data } = ev.detail;
data.forEach(d => removeTrain(d.toString().split("-")[1]));
ev.detail?.data?.forEach(d => removeTrain(d.toString().split("-")[1]));
}

teardown() {
Expand Down
1 change: 1 addition & 0 deletions assets/ts/stop/components/StopMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const StopMap = ({
selectedRoute
}: Props): ReactElement<HTMLElement> => {
const mapConfig = useMapConfig();
if (!mapConfig) return <></>;
const iconName = routeToModeIconName(selectedRoute);
const mapData = {
// TODO: Default center on the selected vehicle
Expand Down
2 changes: 1 addition & 1 deletion lib/dotcom_web/controllers/event_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule DotcomWeb.EventController do
|> async_assign_default(
:events,
fn ->
Map.get(events_by_year, conn.assigns.year)
Map.get(events_by_year, conn.assigns.year, [])
end,
[]
)
Expand Down
13 changes: 6 additions & 7 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,26 @@ defmodule DotCom.Mixfile do
end

defp compile_assets(_) do
# starts the Phoenix framework mix phx.digest command, that takes content
# from assets/static and processes it into priv/static
print("(1/3) mix phx.digest")
Mix.Task.run("phx.digest", [])

# builds the node script that lets us render some react components
# server-side, compiling assets/react_app.js,
# outputting react_renderer/dist/app.js
print("(2/3) webpack --config webpack.config.react_app.js --env.production")
print("(1/3) webpack --config webpack.config.react_app.js --env.production")

{_, 0} =
System.cmd("npm", ["run", "--prefix", "assets", "webpack:build:react"],
stderr_to_stdout: true
)

# 3 - transpiles/builds our typescript/CSS/everything else for production
print("(3/3) webpack --config webpack.config.prod.js --env.production (long)")
print("2/3) webpack --config webpack.config.prod.js --env.production (long)")

{_, 0} =
System.cmd("npm", ["run", "--prefix", "assets", "webpack:build"], stderr_to_stdout: true)

# starts the Phoenix framework mix phx.digest command, that takes content
# from assets/static and processes it into priv/static
print("(3/3) mix phx.digest")

Mix.Task.run("phx.digest", [])
end

Expand Down

0 comments on commit 0573659

Please sign in to comment.