|
|
|
@ -19,6 +19,11 @@ import { useTheme } from 'styled-components';
|
|
|
|
import { useNetwork } from '../hooks/useNetwork';
|
|
|
|
import { useNetwork } from '../hooks/useNetwork';
|
|
|
|
import { Snode } from '../data/data';
|
|
|
|
import { Snode } from '../data/data';
|
|
|
|
import { onionPathModal } from '../state/ducks/modalDialog';
|
|
|
|
import { onionPathModal } from '../state/ducks/modalDialog';
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
getFirstOnionPath,
|
|
|
|
|
|
|
|
getFirstOnionPathLength,
|
|
|
|
|
|
|
|
getOnionPathsCount,
|
|
|
|
|
|
|
|
} from '../state/selectors/onions';
|
|
|
|
|
|
|
|
|
|
|
|
export type StatusLightType = {
|
|
|
|
export type StatusLightType = {
|
|
|
|
glowStartDelay: number;
|
|
|
|
glowStartDelay: number;
|
|
|
|
@ -27,8 +32,7 @@ export type StatusLightType = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const OnionPathModalInner = () => {
|
|
|
|
const OnionPathModalInner = () => {
|
|
|
|
const onionNodes = useSelector((state: StateType) => state.onionPaths.snodePath);
|
|
|
|
const onionPath = useSelector(getFirstOnionPath);
|
|
|
|
const onionPath = onionNodes;
|
|
|
|
|
|
|
|
// including the device and destination in calculation
|
|
|
|
// including the device and destination in calculation
|
|
|
|
const glowDuration = onionPath.length + 2;
|
|
|
|
const glowDuration = onionPath.length + 2;
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,7 +40,7 @@ const OnionPathModalInner = () => {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: window.i18n('device'),
|
|
|
|
label: window.i18n('device'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
...onionNodes,
|
|
|
|
...onionPath,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: window.i18n('destination'),
|
|
|
|
label: window.i18n('destination'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -125,29 +129,21 @@ export const ActionPanelOnionStatusLight = (props: {
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
const { isSelected, handleClick } = props;
|
|
|
|
const { isSelected, handleClick } = props;
|
|
|
|
|
|
|
|
|
|
|
|
let iconColor;
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
const theme = useTheme();
|
|
|
|
const firstOnionPath = useSelector((state: StateType) => state.onionPaths.snodePath);
|
|
|
|
const onionPathsCount = useSelector(getOnionPathsCount);
|
|
|
|
const hasOnionPath = firstOnionPath.length > 2;
|
|
|
|
const firstPathLength = useSelector(getFirstOnionPathLength);
|
|
|
|
|
|
|
|
const isOnline = useNetwork();
|
|
|
|
|
|
|
|
|
|
|
|
// Set icon color based on result
|
|
|
|
// Set icon color based on result
|
|
|
|
const red = theme.colors.destructive;
|
|
|
|
const red = theme.colors.destructive;
|
|
|
|
const green = theme.colors.accent;
|
|
|
|
const green = theme.colors.accent;
|
|
|
|
const orange = theme.colors.warning;
|
|
|
|
const orange = theme.colors.warning;
|
|
|
|
|
|
|
|
|
|
|
|
iconColor = hasOnionPath ? theme.colors.accent : theme.colors.destructive;
|
|
|
|
// start with red
|
|
|
|
const onionState = useSelector((state: StateType) => state.onionPaths);
|
|
|
|
let iconColor = red;
|
|
|
|
|
|
|
|
//if we are not online or the first path is not valid, we keep red as color
|
|
|
|
iconColor = red;
|
|
|
|
if (isOnline && firstPathLength > 1) {
|
|
|
|
const isOnline = useNetwork();
|
|
|
|
iconColor = onionPathsCount > 2 ? green : onionPathsCount > 1 ? orange : red;
|
|
|
|
if (!(onionState && onionState.snodePath) || !isOnline) {
|
|
|
|
|
|
|
|
iconColor = red;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const onionSnodePath = onionState.snodePath;
|
|
|
|
|
|
|
|
if (onionState && onionSnodePath && onionSnodePath.length > 0) {
|
|
|
|
|
|
|
|
const onionNodeCount = onionSnodePath.length;
|
|
|
|
|
|
|
|
iconColor = onionNodeCount > 2 ? green : onionNodeCount > 1 ? orange : red;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|