当該駅情報を追加、U,Sのバグ修正
This commit is contained in:
parent
019486f665
commit
81bb5326f2
@ -58,7 +58,7 @@ export default function LED_vision(props) {
|
||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||
const { areaInfo } = useAreaInfo();
|
||||
const { areaInfo, areaStationID } = useAreaInfo();
|
||||
|
||||
useEffect(() => {
|
||||
AS.getItem("LEDSettings/trainIDSwitch").then((data) => {
|
||||
|
@ -4,6 +4,7 @@ const initialState = {
|
||||
areaInfo: "",
|
||||
setAreainfo: () => {},
|
||||
areaIconBadgeText: "",
|
||||
areaStationID: [],
|
||||
};
|
||||
|
||||
const AreaInfoContext = createContext(initialState);
|
||||
@ -11,22 +12,310 @@ const AreaInfoContext = createContext(initialState);
|
||||
export const useAreaInfo = () => {
|
||||
return useContext(AreaInfoContext);
|
||||
};
|
||||
const setoStationID = [
|
||||
"Y00",
|
||||
"Y01",
|
||||
"Y02",
|
||||
"Y03",
|
||||
"Y04",
|
||||
"Y05",
|
||||
"Y06",
|
||||
"Y07",
|
||||
"Y08",
|
||||
"Y09",
|
||||
"Y10",
|
||||
"Y11",
|
||||
"Y12",
|
||||
];
|
||||
const yosan1StationID = [
|
||||
"Y12",
|
||||
"Y13",
|
||||
"Y14",
|
||||
"Y15",
|
||||
"Y16",
|
||||
"Y17",
|
||||
"Y18",
|
||||
"Y19",
|
||||
"Y20",
|
||||
"Y21",
|
||||
"Y22",
|
||||
"Y23",
|
||||
"Y24",
|
||||
"Y25",
|
||||
"Y26",
|
||||
"Y27",
|
||||
"Y28",
|
||||
"Y29",
|
||||
"Y30",
|
||||
"Y31",
|
||||
"Y32",
|
||||
"Y33",
|
||||
"Y34",
|
||||
"Y35",
|
||||
"Y36",
|
||||
"Y37",
|
||||
"Y38",
|
||||
"Y39",
|
||||
"Y40",
|
||||
"Y41",
|
||||
"Y42",
|
||||
"Y43",
|
||||
"Y44",
|
||||
"Y45",
|
||||
"Y46",
|
||||
"Y47",
|
||||
"Y48",
|
||||
"Y49",
|
||||
"Y50",
|
||||
"Y51",
|
||||
"Y52",
|
||||
"Y53",
|
||||
"Y54",
|
||||
"Y55",
|
||||
];
|
||||
const yosan2StationID = [
|
||||
"U00",
|
||||
"U01",
|
||||
"U02",
|
||||
"U02-1",
|
||||
"U03",
|
||||
"U04",
|
||||
"U05",
|
||||
"U06",
|
||||
"U07",
|
||||
"U08",
|
||||
"U09",
|
||||
"U10",
|
||||
"U11",
|
||||
"U12",
|
||||
"U13",
|
||||
"U14",
|
||||
"U15",
|
||||
"U16",
|
||||
"U17",
|
||||
"U18",
|
||||
"U19",
|
||||
"U20",
|
||||
"U21",
|
||||
"U22",
|
||||
"U23",
|
||||
"U24",
|
||||
"U25",
|
||||
"U26",
|
||||
"U27",
|
||||
"U28",
|
||||
"S06",
|
||||
"S07",
|
||||
"S08",
|
||||
"S09",
|
||||
"S10",
|
||||
"S11",
|
||||
"S12",
|
||||
"S13",
|
||||
"S14",
|
||||
"S15",
|
||||
"S16",
|
||||
"S17",
|
||||
"S18",
|
||||
];
|
||||
const dosan1StationID = [
|
||||
"D12",
|
||||
"D13",
|
||||
"D14",
|
||||
"D15",
|
||||
"D16",
|
||||
"D17",
|
||||
"D18",
|
||||
"D19",
|
||||
"D20",
|
||||
"D21",
|
||||
"D22",
|
||||
"D23",
|
||||
"D24",
|
||||
"D25",
|
||||
"D26",
|
||||
"D27",
|
||||
"D28",
|
||||
"D29",
|
||||
"D30",
|
||||
"D31",
|
||||
"D32",
|
||||
"D33",
|
||||
"D34",
|
||||
"D35",
|
||||
"D36",
|
||||
"D37",
|
||||
"D38",
|
||||
"D39",
|
||||
"D40",
|
||||
"D41",
|
||||
"D42",
|
||||
"D43",
|
||||
"D44",
|
||||
"D45",
|
||||
];
|
||||
const dosan2StationID = [
|
||||
"K00",
|
||||
"K01",
|
||||
"K02",
|
||||
"K03",
|
||||
"K04",
|
||||
"K05",
|
||||
"K06",
|
||||
"K07",
|
||||
"K08",
|
||||
"K08-1",
|
||||
"K09",
|
||||
"K10",
|
||||
"K11",
|
||||
"K12",
|
||||
"K13",
|
||||
"K14",
|
||||
"K15",
|
||||
"K16",
|
||||
"K17",
|
||||
"K18",
|
||||
"K19",
|
||||
"K20",
|
||||
"K21",
|
||||
"K22",
|
||||
"K23",
|
||||
"K24",
|
||||
"K25",
|
||||
"K26",
|
||||
];
|
||||
|
||||
const kotokuStationID = [
|
||||
"T00",
|
||||
"T01",
|
||||
"T02",
|
||||
"T03",
|
||||
"T04",
|
||||
"T05",
|
||||
"T06",
|
||||
"T07",
|
||||
"T08",
|
||||
"T09",
|
||||
"T10",
|
||||
"T11",
|
||||
"T12",
|
||||
"T13",
|
||||
"T14",
|
||||
"T15",
|
||||
"T16",
|
||||
"T17",
|
||||
"T18",
|
||||
"T19",
|
||||
"T20",
|
||||
"T21",
|
||||
"T22",
|
||||
"T23",
|
||||
"T24",
|
||||
"T25",
|
||||
"T26",
|
||||
"T27",
|
||||
"T28",
|
||||
];
|
||||
const mugiStationID = [
|
||||
"M00",
|
||||
"M01",
|
||||
"M02",
|
||||
"M03",
|
||||
"M04",
|
||||
"M05",
|
||||
"M06",
|
||||
"M07",
|
||||
"M08",
|
||||
"M09",
|
||||
"M10",
|
||||
"M11",
|
||||
"M12",
|
||||
"M13",
|
||||
"M14",
|
||||
"M15",
|
||||
"M16",
|
||||
"M17",
|
||||
"M18",
|
||||
"M19",
|
||||
"M20",
|
||||
"M21",
|
||||
"M22",
|
||||
"M23",
|
||||
"M24",
|
||||
"M25",
|
||||
"M26",
|
||||
"M27",
|
||||
];
|
||||
const tokushimaStationID = [
|
||||
"B00",
|
||||
"B01",
|
||||
"B02",
|
||||
"B03",
|
||||
"B04",
|
||||
"B05",
|
||||
"B06",
|
||||
"B07",
|
||||
"B08",
|
||||
"B09",
|
||||
"B10",
|
||||
"B11",
|
||||
"B12",
|
||||
"B13",
|
||||
"B14",
|
||||
"B15",
|
||||
"B16",
|
||||
"B17",
|
||||
"B18",
|
||||
"B19",
|
||||
"B20",
|
||||
"B21",
|
||||
"B22",
|
||||
"B23",
|
||||
"B24",
|
||||
"B25",
|
||||
];
|
||||
|
||||
const narutoStationID = ["N04", "N05", "N06", "N07", "N08", "N09", "N10"];
|
||||
const yodoStationID = [
|
||||
"G27",
|
||||
"G28",
|
||||
"G29",
|
||||
"G30",
|
||||
"G31",
|
||||
"G32",
|
||||
"G33",
|
||||
"G34",
|
||||
"G35",
|
||||
"G36",
|
||||
"G37",
|
||||
"G38",
|
||||
"G39",
|
||||
"G40",
|
||||
"G41",
|
||||
"G42",
|
||||
"G43",
|
||||
"G44",
|
||||
"G45",
|
||||
"G46",
|
||||
"G47",
|
||||
];
|
||||
|
||||
const areaStationPair = {
|
||||
seto: ["Y"],
|
||||
yosan1: ["Y"],
|
||||
yosan2: ["U"],
|
||||
dosan1: ["D"],
|
||||
dosan2: ["K"],
|
||||
kotoku: ["T"],
|
||||
mugi: ["M"],
|
||||
tokushima: ["B"],
|
||||
naruto: ["N"],
|
||||
yodo: ["G"],
|
||||
seto: { id: "Y", stationID: setoStationID },
|
||||
yosan1: { id: "Y", stationID: yosan1StationID },
|
||||
yosan2: { id: "U,S", stationID: yosan2StationID },
|
||||
dosan1: { id: "D", stationID: dosan1StationID },
|
||||
dosan2: { id: "K", stationID: dosan2StationID },
|
||||
kotoku: { id: "T", stationID: kotokuStationID },
|
||||
mugi: { id: "M", stationID: mugiStationID },
|
||||
tokushima: { id: "B", stationID: tokushimaStationID },
|
||||
naruto: { id: "N", stationID: narutoStationID },
|
||||
yodo: { id: "G", stationID: yodoStationID },
|
||||
};
|
||||
export const AreaInfoProvider = ({ children }) => {
|
||||
const [areaInfo, setAreaInfo] = useState("");
|
||||
const [areaIconBadgeText, setAreaIconBadgeText] = useState("");
|
||||
const [areaStationID, setAreaStationID] = useState([]);
|
||||
const getAreaData = () => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
||||
@ -39,7 +328,18 @@ export const AreaInfoProvider = ({ children }) => {
|
||||
if (!d.data) return;
|
||||
const text = d.data
|
||||
.filter((e) => e.status)
|
||||
.map((e) => `${areaStationPair[e.area].join("")}`);
|
||||
.map((e) => {
|
||||
return `${areaStationPair[e.area].id}`;
|
||||
});
|
||||
let stationIDList = [];
|
||||
d.data
|
||||
.filter((e) => e.status)
|
||||
.forEach((e) => {
|
||||
stationIDList = stationIDList.concat(
|
||||
areaStationPair[e.area].stationID
|
||||
);
|
||||
});
|
||||
setAreaStationID(stationIDList);
|
||||
setAreaIconBadgeText(text.length == 0 ? "!" : text.join(","));
|
||||
});
|
||||
};
|
||||
@ -47,7 +347,7 @@ export const AreaInfoProvider = ({ children }) => {
|
||||
useInterval(getAreaData, 60000); //60秒毎に全在線列車取得
|
||||
return (
|
||||
<AreaInfoContext.Provider
|
||||
value={{ areaInfo, setAreaInfo, areaIconBadgeText }}
|
||||
value={{ areaInfo, setAreaInfo, areaIconBadgeText, areaStationID }}
|
||||
>
|
||||
{children}
|
||||
</AreaInfoContext.Provider>
|
||||
|
Loading…
Reference in New Issue
Block a user