From 7386ec09fcab0ecb99e8a2d587cb9e71453c1921 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 14 Mar 2026 17:23:24 +0000 Subject: [PATCH] feat(felica): update station label handling for non-transit process types --- components/Settings/FelicaHistoryPage.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/components/Settings/FelicaHistoryPage.tsx b/components/Settings/FelicaHistoryPage.tsx index edc6917..23b1475 100644 --- a/components/Settings/FelicaHistoryPage.tsx +++ b/components/Settings/FelicaHistoryPage.tsx @@ -26,6 +26,19 @@ const PROCESS_TYPE_LABEL: Record = { 0x62: "チャージ", }; +// byte[6-9] が駅コードではなく端末ID等として使われる processType +// (metrodroid の isProductSale / CONSOLE_CHARGE 相当) +// terminalType (byte[0]) が 0xC7(POS) / 0xC8(自販機) の場合も同様 +const NON_TRANSIT_PROCESS_TYPES = new Set([ + 0x46, // 物販 + 0x62, // チャージ + 0x14, // タクシー +]); +const NON_TRANSIT_TERMINAL_TYPES = new Set([ + 0xc7, // POS端末 + 0xc8, // 自動販売機 +]); + function processLabel(processType: number): string { return PROCESS_TYPE_LABEL[processType] ?? `0x${processType.toString(16).toUpperCase().padStart(2, "0")}`; } @@ -42,8 +55,13 @@ function HistoryRow({ entry, index }: { entry: FelicaHistoryEntry; index: number const label = processLabel(entry.processType); const regionCode = entry.regionCode ?? 0; - const inStationLabel = stationLabel(regionCode, entry.inLineCode, entry.inStationCode); - const outStationLabel = stationLabel(regionCode, entry.outLineCode, entry.outStationCode); + // 物販・チャージ・POS端末などの場合は byte[6-9] が駅コードではないので表示しない + const isTransit = + !NON_TRANSIT_PROCESS_TYPES.has(entry.processType) && + !NON_TRANSIT_TERMINAL_TYPES.has(entry.terminalType); + + const inStationLabel = isTransit ? stationLabel(regionCode, entry.inLineCode, entry.inStationCode) : ""; + const outStationLabel = isTransit ? stationLabel(regionCode, entry.outLineCode, entry.outStationCode) : ""; const showStations = inStationLabel !== "" || outStationLabel !== ""; return (