dmencu 2.1.20 → 2.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,8 @@ import {
7
7
  focusToId,
8
8
  scrollToTop,
9
9
  scrollToBottom,
10
- materialIoIconsSvgPath
10
+ materialIoIconsSvgPath,
11
+ useOnlineStatus
11
12
  } from "./render-general";
12
13
  import {Bloque, BotonFormulario,
13
14
  CasilleroBase, CasoState, ConjuntoPreguntas, Consistencia,
@@ -2052,13 +2053,7 @@ setHojaDeRutaDespliegue((_props:{})=>{
2052
2053
  var {modo} = useSelector((state:CasoState)=>({modo:state.modo}));
2053
2054
  var feedbackRowValidator = getFeedbackRowValidator()
2054
2055
  const dispatch = useDispatch();
2055
- const updateOnlineStatus = function(){
2056
- setOnline(window.navigator.onLine);
2057
- }
2058
- const appVersion = getCacheVersion();
2059
- const [online, setOnline] = useState(window.navigator.onLine);
2060
- window.addEventListener('online', updateOnlineStatus);
2061
- window.addEventListener('offline', updateOnlineStatus);
2056
+ const online = useOnlineStatus();
2062
2057
  const modoDM:ModoDM = my.getLocalVar(MODO_DM_LOCALSTORAGE_KEY);
2063
2058
  return (
2064
2059
  <>
@@ -2190,12 +2185,8 @@ export function AppDmEncu(){
2190
2185
  }
2191
2186
 
2192
2187
  function PantallaInicialSinCarga(_props:{}){
2193
- const updateOnlineStatus = function(){
2194
- setOnline(window.navigator.onLine);
2195
- }
2196
- const [online, setOnline] = useState(window.navigator.onLine);
2197
- window.addEventListener('online', updateOnlineStatus);
2198
- window.addEventListener('offline', updateOnlineStatus);
2188
+ const online = useOnlineStatus();
2189
+
2199
2190
  const paragraphStyles={fontSize:"1.2rem", fontWeight:600, padding: "5px 10px"};
2200
2191
  const modoDM:ModoDM = my.getLocalVar(MODO_DM_LOCALSTORAGE_KEY);
2201
2192
  return (
@@ -200,6 +200,22 @@ const theme = createTheme({
200
200
  },
201
201
  });
202
202
 
203
+ export function useOnlineStatus() {
204
+ const [online, setOnline] = useState(window.navigator.onLine);
205
+
206
+ useEffect(() => {
207
+ const handler = () => setOnline(window.navigator.onLine);
208
+ window.addEventListener('online', handler);
209
+ window.addEventListener('offline', handler);
210
+ return () => {
211
+ window.removeEventListener('online', handler);
212
+ window.removeEventListener('offline', handler);
213
+ };
214
+ }, []);
215
+
216
+ return online;
217
+ }
218
+
203
219
  export function RenderPrincipal<T,T2 extends Action>(props:{store:Store<T,T2>, dispatchers:IDispatchers, mensajeRetorno:string, children:React.ReactNode}){
204
220
  return <React.StrictMode>
205
221
  <Provider store={props.store}>