|
|
@ -1,6 +1,7 @@ |
|
|
|
import { useState } from "react"; |
|
|
|
import getFieldsAnswers from "../api/RequestFieldsAnswers/getFieldsAnswers"; |
|
|
|
import webSocketClient from "../api/Websockets/webSocketClient"; |
|
|
|
import cache from "../utility/cache"; |
|
|
|
|
|
|
|
async function getPluvStation_data(id) { |
|
|
|
const result = await getFieldsAnswers.fieldsAnswers(null, id); |
|
|
@ -58,15 +59,18 @@ async function getPluviometerStation(userId, setPluviometerStation) { |
|
|
|
pluvStation_data.data.responseData.array_to_json[0] |
|
|
|
); |
|
|
|
setPluviometerStation(pluvObject); |
|
|
|
cache.store(socketObject, JSON.stringify(pluvObject)) |
|
|
|
} else { |
|
|
|
setPluviometerStation(false); |
|
|
|
cache.store(socketObject, false) |
|
|
|
} |
|
|
|
socketObject.close(); |
|
|
|
}; |
|
|
|
|
|
|
|
socketObject.onerror = (e) => { |
|
|
|
socketObject.onerror = async (e) => { |
|
|
|
const dataCache = await cache.get(url); |
|
|
|
console.log(e.message); |
|
|
|
setPluviometerStation(undefined); |
|
|
|
setPluviometerStation(dataCache); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|