Merge commit 'dd7da102c43348a5420a4b616509d37c8d03a65f'

This commit is contained in:
harukin-expo-dev-env 2024-03-27 15:52:25 +00:00
commit 2d0ad8d59e
3 changed files with 40 additions and 11 deletions

View File

@ -171,7 +171,7 @@ export default function Setting() {
textAlignVertical: "center", textAlignVertical: "center",
}} }}
> >
内部バージョン: 5.0.3.1 内部バージョン: 5.0.3.2
</Text> </Text>
<View style={{ flex: 1 }} /> <View style={{ flex: 1 }} />
</View> </View>

View File

@ -12,9 +12,25 @@ export const useAllTrainDiagram = () => {
export const AllTrainDiagramProvider = ({ children }) => { export const AllTrainDiagramProvider = ({ children }) => {
const [allTrainDiagram, setAllTrainDiagram] = useState(); const [allTrainDiagram, setAllTrainDiagram] = useState();
const customData = { const customData = {};
};
useEffect(() => { useEffect(() => {
fetch(
"http://n8n.haruk.in/webhook/CrowdTh%E2%82%AC71m3Ra7!ngLead%E2%82%ACr$"
)
.then((res) => res.json())
.then((res) => {
const data = {};
res.forEach((d) => {
const keys = Object.keys(d);
data[keys] = d[keys];
});
return data;
})
.then((res) => {
Object.assign(res, customData);
setAllTrainDiagram(res);
})
.catch((d) => {
fetch( fetch(
"https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec" "https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec"
) )
@ -31,6 +47,7 @@ export const AllTrainDiagramProvider = ({ children }) => {
Object.assign(res, customData); Object.assign(res, customData);
setAllTrainDiagram(res); setAllTrainDiagram(res);
}); });
});
}, []); }, []);
return ( return (

View File

@ -26,7 +26,17 @@ export const useCurrentTrain = () => {
export const CurrentTrainProvider = ({ children }) => { export const CurrentTrainProvider = ({ children }) => {
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 } const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
const getCurrentTrain = () => const getCurrentTrain = () => {
fetch("https://n8n.haruk.in/webhook/c501550c-7d1b-4e50-927b-4429fe18931a")
.then((response) => response.json())
.then((d) =>
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
)
.then((d) => {
setCurrentTrain(d);
setCurrentTrainLoading("success");
})
.catch(() => {
fetch( fetch(
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec", "https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
HeaderConfig HeaderConfig
@ -43,6 +53,8 @@ export const CurrentTrainProvider = ({ children }) => {
console.log("えらー"); console.log("えらー");
setCurrentTrainLoading("error"); setCurrentTrainLoading("error");
}); });
});
};
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得 useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得