onionpath status only has ip needed

pull/1884/head
audric 4 years ago
parent 38665e105a
commit ea2dbb4a69

@ -146,8 +146,13 @@ export async function getOnionPath(toExclude?: Snode): Promise<Array<Snode>> {
window.inboxStore?.dispatch(updateOnionPaths([])); window.inboxStore?.dispatch(updateOnionPaths([]));
} }
} else { } else {
if (!_.isEqual(window.inboxStore?.getState().onionPaths.snodePaths, onionPaths)) { const ipsOnly = onionPaths.map(m =>
window.inboxStore?.dispatch(updateOnionPaths(onionPaths)); m.map(c => {
return { ip: c.ip };
})
);
if (!_.isEqual(window.inboxStore?.getState().onionPaths.snodePaths, ipsOnly)) {
window.inboxStore?.dispatch(updateOnionPaths(ipsOnly));
} }
} }

@ -1,13 +1,12 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { Snode } from '../../data/data';
export type OnionState = { export type OnionState = {
snodePaths: Array<Array<Snode>>; snodePaths: Array<Array<{ ip: string }>>;
isOnline: boolean; isOnline: boolean;
}; };
export const initialOnionPathState = { export const initialOnionPathState = {
snodePaths: new Array<Array<Snode>>(), snodePaths: new Array<Array<{ ip: string }>>(),
isOnline: false, isOnline: false,
}; };
@ -18,7 +17,7 @@ const onionSlice = createSlice({
name: 'onionPaths', name: 'onionPaths',
initialState: initialOnionPathState, initialState: initialOnionPathState,
reducers: { reducers: {
updateOnionPaths(state: OnionState, action: PayloadAction<Array<Array<Snode>>>) { updateOnionPaths(state: OnionState, action: PayloadAction<Array<Array<{ ip: string }>>>) {
state.snodePaths = action.payload; state.snodePaths = action.payload;
return state; return state;
}, },

@ -2,7 +2,6 @@ import { createSelector } from 'reselect';
import { StateType } from '../reducer'; import { StateType } from '../reducer';
import { OnionState } from '../ducks/onion'; import { OnionState } from '../ducks/onion';
import { Snode } from '../../data/data';
import { SectionType } from '../../state/ducks/section'; import { SectionType } from '../../state/ducks/section';
export const getOnionPaths = (state: StateType): OnionState => state.onionPaths; export const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
@ -14,12 +13,12 @@ export const getOnionPathsCount = createSelector(
export const getFirstOnionPath = createSelector( export const getFirstOnionPath = createSelector(
getOnionPaths, getOnionPaths,
(state: OnionState): Array<Snode> => state.snodePaths?.[0] || [] (state: OnionState): Array<{ ip: string }> => state.snodePaths?.[0] || []
); );
export const getFirstOnionPathLength = createSelector( export const getFirstOnionPathLength = createSelector(
getFirstOnionPath, getFirstOnionPath,
(state: Array<Snode>): number => state.length || 0 (state: Array<{ ip: string }>): number => state.length || 0
); );
export const getIsOnline = createSelector( export const getIsOnline = createSelector(

Loading…
Cancel
Save