Skip to content

Commit

Permalink
Clean up, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 14, 2024
1 parent e198fa2 commit 3357c2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/components/PageLayout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const needsScopeSelector = (): boolean => {
case 'network':
return RouteUtils.getEnabledNetworksForLayer(getFixedLayer()!).length > 1
case 'layer':
return RouteUtils.getEnabledLayersForNetwork(getFixedNetwork()!).length > 1
return RouteUtils.getVisibleLayersForNetwork(getFixedNetwork()!).length > 1
case 'both':
return RouteUtils.getEnabledScopes().length > 1
case 'none':
Expand Down
5 changes: 5 additions & 0 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Network } from '../../types/network'
import { SearchScope } from '../../types/searchScope'
import { isStableDeploy } from '../../config'
import { getSearchTermFromRequest } from '../components/Search/search-utils'
import { isLayerNotHidden } from '../../types/layers'

export const isTesting = () => process.env.NODE_ENV === 'test'

Expand Down Expand Up @@ -154,6 +155,10 @@ export abstract class RouteUtils {
return Object.values(Layer).filter(layer => RouteUtils.ENABLED_LAYERS_FOR_NETWORK[network][layer])
}

static getVisibleLayersForNetwork(network: Network): Layer[] {
return this.getEnabledLayersForNetwork(network).filter(isLayerNotHidden)
}

static getProposalsRoute = (network: Network) => {
return `${getNetworkPath(network)}/consensus/proposal`
}
Expand Down
1 change: 1 addition & 0 deletions src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export const doesAnyOfTheseLayersSupportEncryptedTransactions = (layers: Layer[]
uniq(layers).some(doesLayerSupportEncryptedTransactions)

export const isLayerHidden = (layer: Layer): boolean => hiddenLayers.includes(layer)
export const isLayerNotHidden = (layer: Layer): boolean => !hiddenLayers.includes(layer)

export const isNotOnHiddenLayer = (item: HasLayer) => !isLayerHidden(item.layer)

0 comments on commit 3357c2e

Please sign in to comment.