Skip to content

Commit

Permalink
Add support for hidden layers in Layer selector
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 13, 2024
1 parent 5afbfe2 commit fea1c18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/components/LayerPicker/LayerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Layer } from '../../../oasis-nexus/api'
import { getLayerLabels } from '../../utils/content'
import { RouteUtils } from '../../utils/route-utils'
import { Network } from '../../../types/network'
import { orderByLayer } from '../../../types/layers'
import { isLayerHidden, orderByLayer } from '../../../types/layers'
import { useScreenSize } from '../../hooks/useScreensize'

type BaseLayerMenuItemProps = {
Expand Down Expand Up @@ -109,6 +109,7 @@ export const LayerMenu: FC<LayerMenuProps> = ({
}) => {
const [hoveredLayer, setHoveredLayer] = useState<undefined | Layer>()
const options = Object.values(Layer)
.filter(layer => !isLayerHidden(layer))
.map(layer => ({
layer,
enabled: RouteUtils.getEnabledLayersForNetwork(selectedNetwork || network).includes(layer),
Expand Down
4 changes: 4 additions & 0 deletions src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const layerOrder: Record<Layer, number> = {
[Layer.cipher]: 4,
}

const hiddenLayers: Layer[] = []

export const orderByLayer = (itemA: HasLayer, itemB: HasLayer): number =>
layerOrder[itemA.layer] - layerOrder[itemB.layer]

Expand All @@ -36,3 +38,5 @@ export const doesLayerSupportEncryptedTransactions = (layer: Layer): boolean =>

export const doesAnyOfTheseLayersSupportEncryptedTransactions = (layers: Layer[] | undefined): boolean =>
uniq(layers).some(doesLayerSupportEncryptedTransactions)

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

0 comments on commit fea1c18

Please sign in to comment.