Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Route Search Remark #182

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prettified Code!
  • Loading branch information
LOOHP authored and actions-user committed May 15, 2024
commit 1c99c74ca069621ecf011bd16185bf76d8d35ffb
9 changes: 6 additions & 3 deletions src/components/route-board/RouteTerminus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ const RouteTerminus = ({ terminus }: RouteTerminus) => {
: JSON.stringify(co) === JSON.stringify(data.co))
) {
if (
stopList[data.stops[co[0]][data.stops[co[0]].length - 1]].name.zh !==
stopList[stops[co[0]][stops[co[0]].length - 1]].name.zh
stopList[data.stops[co[0]][data.stops[co[0]].length - 1]].name
.zh !== stopList[stops[co[0]][stops[co[0]].length - 1]].name.zh
) {
remark = t("開往") + dest[i18n.language];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use optional chaining to safely access properties.

- remark = t("開往") + dest[i18n.language];
- remark = t("從") + orig[i18n.language] + t("開出");
+ remark = t("開往") + dest?.[i18n.language];
+ remark = t("從") + orig?.[i18n.language] + t("開出");

Ensure that the code does not throw runtime errors when the language key is not found in the dest or orig objects.

Also applies to: 60-60, 70-70, 73-73

} else if (stopList[data.stops[co[0]][0]].name.zh !== stopList[stops[co[0]][0]].name.zh) {
} else if (
stopList[data.stops[co[0]][0]].name.zh !==
stopList[stops[co[0]][0]].name.zh
) {
if (!terminus.nlbId) {
remark = t("從") + orig[i18n.language] + t("開出");
}
Expand Down