refactor: improve redirect

This commit is contained in:
Carlos Valente
2024-12-13 11:02:07 +01:00
committed by Carlos Valente
parent 4c6acc4013
commit d46dfcf82e
3 changed files with 20 additions and 5 deletions
@@ -238,3 +238,12 @@ export const usePing = () => {
return useRuntimeStore(featureSelector);
};
/** convert ping into a derived value which changes less often */
export const useIsOnline = () => {
const featureSelector = (state: RuntimeStore) => ({
isOnline: state.ping > 0,
});
return useRuntimeStore(featureSelector);
};