You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/ts/state/selectors/onions.ts

24 lines
724 B
TypeScript

import { createSelector } from 'reselect';
import { StateType } from '../reducer';
import { SectionType } from '../../components/session/ActionsPanel';
import { OnionState } from '../ducks/onion';
import { Snode } from '../../data/data';
export const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
export const getOnionPathsCount = createSelector(
getOnionPaths,
(state: OnionState): SectionType => state.snodePaths.length
);
export const getFirstOnionPath = createSelector(
getOnionPaths,
(state: OnionState): Array<Snode> => state.snodePaths?.[0] || []
);
export const getFirstOnionPathLength = createSelector(
getFirstOnionPath,
(state: Array<Snode>): number => state.length || 0
);