Skip to content

Commit

Permalink
feat(refactor): Use package.json version (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat authored Apr 23, 2024
1 parent 6cb4d49 commit 2b9cf15
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-staking-dashboard",
"version": "1.4.3",
"version": "1.4.4",
"type": "module",
"license": "GPL-3.0-only",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { stringToU8a } from '@polkadot/util';
/*
* Global Constants
*/
export const AppVersion = '1.4.3';
export const DappName = 'Polkadot Staking Dashboard';
export const PolkadotUrl = 'https://polkadot.network/features/staking/';
export const ManualSigners = ['ledger', 'vault'];
Expand Down
8 changes: 4 additions & 4 deletions src/contexts/Migrate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import type { ReactNode } from 'react';
import { createContext, useState } from 'react';
import { AppVersion } from 'consts';
import { useApi } from 'contexts/Api';
import { useEffectIgnoreInitial } from '@w3ux/hooks';
import { useSyncing } from 'hooks/useSyncing';
import { version } from '../../../package.json';

export const MigrateContext = createContext<null>(null);

Expand All @@ -18,7 +18,7 @@ export const MigrateProvider = ({ children }: { children: ReactNode }) => {
const localAppVersion = localStorage.getItem('app_version');

// Store whether the migration check has taken place.
const [done, setDone] = useState<boolean>(localAppVersion === AppVersion);
const [done, setDone] = useState<boolean>(localAppVersion === version);

// Removes local era stakers data and locale data.
const removeLocalErasAndLocales = () => {
Expand All @@ -42,7 +42,7 @@ export const MigrateProvider = ({ children }: { children: ReactNode }) => {
useEffectIgnoreInitial(() => {
if (isReady && !syncing && !done) {
// Carry out migrations if local version is different to current version.
if (localAppVersion !== AppVersion) {
if (localAppVersion !== version) {
// Added in 1.4.3
//
// Remove local era stakers data and locale data. Paged rewards are now active and local
Expand All @@ -54,7 +54,7 @@ export const MigrateProvider = ({ children }: { children: ReactNode }) => {
// Finally,
//
// Update local version to current app version.
localStorage.setItem('app_version', AppVersion);
localStorage.setItem('app_version', version);
setDone(true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/locale/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { enGB, zhCN } from 'date-fns/locale';
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import { AppVersion } from 'consts';
import { version } from '../../package.json';
import type { AnyJson } from 'types';
import baseEn from './en/base.json';
import helpEn from './en/help.json';
Expand Down Expand Up @@ -51,7 +51,7 @@ export const fallbackResources = {

// Refresh local storage resources if in development, or if new app version is present.
if (
localStorage.getItem('app_version') !== AppVersion ||
localStorage.getItem('app_version') !== version ||
import.meta.env.MODE === 'development'
) {
localStorage.removeItem('lng_resources');
Expand Down

0 comments on commit 2b9cf15

Please sign in to comment.