Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: load available networks #1217

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frontend/components/bc/DataWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const {
const { tick } = useInterval(12)
const { refreshLatestState } = useLatestStateStore()
const {
loadAvailableNetworks,
setCurrentNetwork,
} = useNetworkStore()

Expand All @@ -19,7 +18,6 @@ await useAsyncData('latest_state', () => refreshLatestState(), {
if (isLoggedIn) {
await useAsyncData('get_user', () => getUser())
}
await useAsyncData('get-supported-networks', () => loadAvailableNetworks())

const { chainIdByDefault } = useRuntimeConfig().public
if (chainIdByDefault) {
Expand Down
99 changes: 0 additions & 99 deletions frontend/components/bc/SearchbarGeneral.vue

This file was deleted.

38 changes: 33 additions & 5 deletions frontend/components/bc/format/FormatTimePassed.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<script setup lang="ts">
import type { StringUnitLength } from 'luxon'
import { useFormat } from '~/composables/useFormat'
import type { AgeFormat } from '~/types/settings'
import { formatGoTimestamp } from '~/utils/format'

const {
formatEpochToDateTime, formatSlotToDateTime,
} = useFormat()

interface Props {
format?: 'global-setting' | AgeFormat,
noUpdate?: boolean,
Expand All @@ -20,6 +15,11 @@ const { t: $t } = useTranslation()
const { timestamp } = useDate()
const { setting } = useGlobalSetting<AgeFormat>('age-format')

const {
epochToTs,
slotToTs,
} = useNetworkStore()

const initTs = ref(timestamp.value) // store the initial timestamp, in case we don't want to auto update

const mappedSetting = computed(() => {
Expand Down Expand Up @@ -78,6 +78,34 @@ const label = computed(() => {

return { text }
})

function formatEpochToDateTime(
epoch: number,
timestamp?: number,
format?: AgeFormat,
style?: StringUnitLength,
locales: string = 'en',
withTime?: boolean,
) {
if (format === 'relative') {
return formatTsToRelative(epochToTs(epoch) ?? 0 * 1000, timestamp, style, locales)
}
return formatTsToAbsolute(epochToTs(epoch) ?? 0 * 1000, locales, withTime)
}

function formatSlotToDateTime(
slot: number,
timestamp?: number,
format?: AgeFormat,
style?: StringUnitLength,
locales: string = 'en',
withTime?: boolean,
) {
if (format === 'relative') {
return formatTsToRelative(slotToTs(slot) ?? 0 * 1000, timestamp, style, locales)
}
return formatTsToAbsolute(slotToTs(slot) ?? 0 * 1000, locales, withTime)
}
</script>

<template>
Expand Down
19 changes: 0 additions & 19 deletions frontend/components/bc/header/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import {
import type { BcHeaderMegaMenu } from '#build/components'
import { useLatestStateStore } from '~/stores/useLatestStateStore'
import { useNetworkStore } from '~/stores/useNetworkStore'
import {
SearchbarColors, SearchbarShape,
} from '~/types/searchbar'
import {
mobileHeaderThreshold, smallHeaderThreshold,
} from '~/types/header'
Expand All @@ -31,7 +28,6 @@ const { width } = useWindowSize()
const { t: $t } = useTranslation()
const { promoCode } = usePromoCode()

const colorMode = useColorMode()
const isSmallScreen = computed(() => width.value < smallHeaderThreshold)
const isMobileScreen = computed(() => width.value < mobileHeaderThreshold)

Expand Down Expand Up @@ -143,21 +139,6 @@ const handleUserMenuSelect = async (value: UserMenuItem) => {
</span>
</span>
</div>

<div class="grid-cell search-bar">
<BcSearchbarGeneral
v-if="showInDevelopment && !isHomePage"
class="bar"
:bar-shape="SearchbarShape.Medium"
:color-theme="
isSmallScreen && colorMode.value != 'dark'
? SearchbarColors.LightBlue
: SearchbarColors.DarkBlue
"
:screen-width-causing-sudden-change="smallHeaderThreshold"
/>
</div>

<div class="grid-cell controls">
<BcCurrencySelection
class="currency"
Expand Down
Loading