From 8f23faacd73415bf336294c001bf42f4a0be2d4d Mon Sep 17 00:00:00 2001 From: harukin-OneMix4 Date: Fri, 15 Dec 2023 02:16:29 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=AB=E3=82=83=E3=83=BC=E3=82=93=E3=82=92?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E6=96=87=E3=81=AB=E3=81=97=E3=80=81?= =?UTF-8?q?=E5=86=8D=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=81=BF=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E8=89=B2=E3=81=8C=E5=A4=89=E5=8C=96=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 5 ++--- Apps.js | 10 ++++++++-- lib/webViewInjectjavascript.js | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/App.js b/App.js index 07b587a..d496cf9 100644 --- a/App.js +++ b/App.js @@ -105,14 +105,13 @@ export function AppContainer() { useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得 const { areaInfo, setAreaInfo } = useAreaInfo(); - const getAreaInfo = () => { + useEffect(() => { fetch( "https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec" ) .then((d) => d.text()) .then((d) => setAreaInfo(d)); - }; - useEffect(getAreaInfo, []); + }, []); return ( diff --git a/Apps.js b/Apps.js index 30c72e7..cc53cde 100644 --- a/Apps.js +++ b/Apps.js @@ -26,6 +26,7 @@ export default function Apps({ navigation, webview, stationData }) { const [iconSetting, setIconSetting] = useState(undefined); const [mapSwitch, setMapSwitch] = useState(undefined); const [stationMenu, setStationMenu] = useState(undefined); + const [LoadError, setLoadError] = useState(false); //列車情報表示関連 const EachTrainInfoAsSR = useRef(null); @@ -127,6 +128,10 @@ export default function Apps({ navigation, webview, stationData }) { } const dataSet = JSON.parse(event.nativeEvent.data); switch (dataSet.type) { + case "LoadError": { + setLoadError(true); + return; + } case "PopUpMenu": { const selectedStationPDFAddress = dataSet.pdf; const findStationEachLine = (selectLine) => { @@ -285,6 +290,7 @@ export default function Apps({ navigation, webview, stationData }) { webview.current.reload()} top={Platform.OS == "ios" ? Constants.statusBarHeight : 0} + LoadError={LoadError} /> { ); }; -const ReloadButton = ({ onPress, top, mapSwitch }) => { +const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => { const styles = { touch: { position: "absolute", @@ -352,7 +358,7 @@ const ReloadButton = ({ onPress, top, mapSwitch }) => { right: 10, width: 50, height: 50, - backgroundColor: "#0099CC", + backgroundColor: LoadError ? "red" : "#0099CC", borderColor: "white", borderStyle: "solid", borderWidth: 1, diff --git a/lib/webViewInjectjavascript.js b/lib/webViewInjectjavascript.js index 8cbfb3a..bceeeeb 100644 --- a/lib/webViewInjectjavascript.js +++ b/lib/webViewInjectjavascript.js @@ -667,7 +667,8 @@ const setStrings = () =>{ document.getElementById('disp').style.overflowX = 'hidden'; }catch(e){ - alert("にゃーん"); + alert("本家サーバーからのデータ取得に失敗しました。"); + window.ReactNativeWebView.postMessage(JSON.stringify({type:"LoadError"})); } } catch (e) {} }