fix: load maxmind data once on mount of status dialog
parent
5f9d3209c8
commit
96809bf5b4
@ -1,27 +1,41 @@
|
|||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
import { StateType } from '../reducer';
|
import { useSelector } from 'react-redux';
|
||||||
import { OnionState } from '../ducks/onion';
|
import { OnionState } from '../ducks/onion';
|
||||||
import { SectionType } from '../ducks/section';
|
import { SectionType } from '../ducks/section';
|
||||||
|
import { StateType } from '../reducer';
|
||||||
|
|
||||||
export const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
|
const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
|
||||||
|
|
||||||
export const getOnionPathsCount = createSelector(
|
const getOnionPathsCount = createSelector(
|
||||||
getOnionPaths,
|
getOnionPaths,
|
||||||
(state: OnionState): SectionType => state.snodePaths.length
|
(state: OnionState): SectionType => state.snodePaths.length
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getFirstOnionPath = createSelector(
|
const getFirstOnionPath = createSelector(
|
||||||
getOnionPaths,
|
getOnionPaths,
|
||||||
(state: OnionState): Array<{ ip: string }> => state.snodePaths?.[0] || []
|
(state: OnionState): Array<{ ip: string }> => state.snodePaths?.[0] || []
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getFirstOnionPathLength = createSelector(
|
const getFirstOnionPathLength = createSelector(
|
||||||
getFirstOnionPath,
|
getFirstOnionPath,
|
||||||
(state: Array<{ ip: string }>): number => state.length || 0
|
(state: Array<{ ip: string }>): number => state.length || 0
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getIsOnline = createSelector(
|
const getIsOnline = createSelector(getOnionPaths, (state: OnionState): boolean => state.isOnline);
|
||||||
getOnionPaths,
|
|
||||||
(state: OnionState): boolean => state.isOnline
|
export const useOnionPathsCount = () => {
|
||||||
);
|
return useSelector(getOnionPathsCount);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useIsOnline = () => {
|
||||||
|
return useSelector(getIsOnline);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useFirstOnionPathLength = () => {
|
||||||
|
return useSelector(getFirstOnionPathLength);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useFirstOnionPath = () => {
|
||||||
|
return useSelector(getFirstOnionPath);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue