Skip to content

Commit

Permalink
Update handling for Ferry
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Apr 14, 2024
1 parent 2c97c92 commit c98d6e3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"core-js": "^3.23.1",
"dayjs": "^1.11.7",
"dom-to-image": "^2.6.0",
"hk-bus-eta": "^3.3.2",
"hk-bus-eta": "^3.3.3",
"i18next": "^23.10.0",
"immer": "^9.0.15",
"leaflet": "^1.9.4",
Expand Down
3 changes: 2 additions & 1 deletion src/components/route-board/BoardTabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const isBoardTab = (
input === "bus" ||
input === "minibus" ||
input === "lightRail" ||
input === "mtr"
input === "mtr" ||
input === "ferry"
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ETA_FORMAT_STR = {

export const TRANSPORT_SEARCH_OPTIONS: Record<BoardTabType, Company[]> = {
recent: ["kmb", "ctb", "lrtfeeder", "nlb", "gmb", "lightRail", "mtr"],
all: ["kmb", "ctb", "lrtfeeder", "nlb", "gmb", "lightRail", "mtr"],
all: ["kmb", "ctb", "lrtfeeder", "nlb", "gmb", "lightRail", "mtr", "sunferry", "fortuneferry", "hkkf"],
bus: ["kmb", "ctb", "lrtfeeder", "nlb"],
minibus: ["gmb"],
lightRail: ["lightRail"],
Expand Down
14 changes: 4 additions & 10 deletions src/hooks/useEtas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useLanguage from "./useTranslation";

export const useEtas = (routeId: string, disable: boolean = false) => {
const {
db: { routeList, stopList },
db: { routeList, stopList, holidays, serviceDayMap },
isVisible,
refreshInterval,
} = useContext(AppContext);
Expand All @@ -21,24 +21,18 @@ export const useEtas = (routeId: string, disable: boolean = false) => {
setEtas(null);
return new Promise((resolve) => resolve([]));
}
if (
routeObj.co.includes("hkkf") ||
routeObj.co.includes("fortuneferry") ||
routeObj.co.includes("sunferry")
) {
setEtas([]);
return Promise.resolve([]);
}
return fetchEtas({
...routeObj,
seq: parseInt(seq, 10),
stopList,
// @ts-ignore
language,
holidays,
serviceDayMap,
}).then((_etas) => {
if (isMounted.current) setEtas(_etas);
});
}, [isVisible, language, routeObj, seq, stopList]);
}, [isVisible, language, routeObj, seq, stopList, holidays, serviceDayMap]);

useEffect(() => {
if (disable) return;
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useStopEtas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useStopEtas = ({
disabled = false,
}: useStopEtasProps) => {
const {
db: { routeList, stopList, serviceDayMap },
db: { routeList, stopList, serviceDayMap, holidays },
isVisible,
refreshInterval,
isRouteFilter,
Expand Down Expand Up @@ -81,6 +81,8 @@ export const useStopEtas = ({
stopList,
// @ts-ignore
language,
holidays,
serviceDayMap,
})
)
).then((_etas) => {
Expand Down Expand Up @@ -119,6 +121,8 @@ export const useStopEtas = ({
stopList,
routeKeys,
isLightRail,
holidays,
serviceDayMap,
]);

useEffect(() => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3888,10 +3888,10 @@ hast-util-whitespace@^2.0.0:
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-2.0.1.tgz#0ec64e257e6fc216c7d14c8a1b74d27d650b4557"
integrity sha512-nAxA0v8+vXSBDt3AnRUNjyRIQ0rD+ntpbAp4LnPkumc5M9yUbSMa4XDU9Q6etY4f1Wp4bNgvc1yjiZtsTTrSng==

hk-bus-eta@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hk-bus-eta/-/hk-bus-eta-3.3.2.tgz#1f3c736cfdf84758dadcc013179aa5de9368af29"
integrity sha512-MUe3AlFKy6NUIEECdV7AADeSYzkNB8Izjpx3B3xb9UKvrBoVej9teCUv7Ng/6Y5z7Qtxan0gB/nGLKk3fCh+YQ==
hk-bus-eta@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/hk-bus-eta/-/hk-bus-eta-3.3.3.tgz#92a195574b9f99a58aaaa2c5cdae126156f587ae"
integrity sha512-M4ml+2yRDZn+jqGlfUNEWrvLDkF+yBiVpP/7qiuR5GhXJnAf8ydMxGdnZcebPCDOYSdUBMT62MHaqs6/eDoNKw==

hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2:
version "3.3.2"
Expand Down

0 comments on commit c98d6e3

Please sign in to comment.