Skip to content

Commit

Permalink
DRY: reuse constants for old interface links
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Dec 18, 2024
1 parent 7e81914 commit ec1c9b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions apps/ui/src/components/App/Topnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { getInstance } from '@snapshot-labs/lock/plugins/vue3';
import { NEW_UI_ANNOUNCEMENT_URL } from '@/helpers/constants';
import { getCacheHash, shorten } from '@/helpers/utils';
import { metadataNetwork, offchainNetworks } from '@/networks';
import { offchainNetworks } from '@/networks';
import { SNAPSHOT_URLS } from '@/networks/offchain';
import { NetworkID } from '@/types';
defineProps<{
Expand Down Expand Up @@ -60,15 +61,9 @@ const searchConfig = computed(() => {
});
const oldInterfaceLink = computed(() => {
const networkSubDomains = {
s: 'v1.',
's-tn': 'testnet.v1.'
};
const [spaceNetwork, spaceId] = ((route.params.space as string) || '').split(
':'
);
const subDomain =
networkSubDomains[spaceNetwork] || networkSubDomains[metadataNetwork];
let path = '';
switch (route.name) {
Expand Down Expand Up @@ -120,7 +115,7 @@ const oldInterfaceLink = computed(() => {
path = '';
}
return `https://${subDomain}snapshot.box/#/${path}`;
return `${SNAPSHOT_URLS[spaceNetwork]}/#/${path}`;
});
async function handleLogin(connector) {
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/networks/offchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const HUB_URLS: Partial<Record<NetworkID, string | undefined>> = {
s: 'https://hub.snapshot.org/graphql',
's-tn': 'https://testnet.hub.snapshot.org/graphql'
};
const SNAPSHOT_URLS: Partial<Record<NetworkID, string | undefined>> = {
export const SNAPSHOT_URLS: Partial<Record<NetworkID, string | undefined>> = {
s: 'https://v1.snapshot.box',
's-tn': 'https://testnet.v1.snapshot.box'
};
Expand Down

0 comments on commit ec1c9b5

Please sign in to comment.