Commit aac7268d authored by Moody Salem's avatar Moody Salem

just drop the git commit hash (more trouble than it's worth)

parent fd162a72
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "cross-env REACT_APP_GIT_COMMIT_HASH=$(git show -s --format=%H) react-scripts build", "build": "react-scripts build",
"ipfs-build": "cross-env PUBLIC_URL=\".\" react-scripts build", "ipfs-build": "cross-env PUBLIC_URL=\".\" react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject", "eject": "react-scripts eject",
......
...@@ -77,9 +77,7 @@ const MenuItem = styled(ExternalLink)` ...@@ -77,9 +77,7 @@ const MenuItem = styled(ExternalLink)`
} }
` `
const CODE_LINK = !!process.env.REACT_APP_GIT_COMMIT_HASH const CODE_LINK = 'https://github.com/Uniswap/uniswap-frontend'
? `https://github.com/Uniswap/uniswap-frontend/tree/${process.env.REACT_APP_GIT_COMMIT_HASH}`
: 'https://github.com/Uniswap/uniswap-frontend'
export default function Menu() { export default function Menu() {
const node = useRef<HTMLDivElement>() const node = useRef<HTMLDivElement>()
......
import { createStore, Store } from 'redux'
import { DEFAULT_DEADLINE_FROM_NOW, INITIAL_ALLOWED_SLIPPAGE } from '../../constants'
import { updateVersion } from './actions'
import reducer, { initialState, UserState } from './reducer'
describe('swap reducer', () => {
let store: Store<UserState>
beforeEach(() => {
store = createStore(reducer, initialState)
})
describe('updateVersion', () => {
it('has no timestamp originally', () => {
expect(store.getState().lastUpdateVersionTimestamp).toBeUndefined()
})
it('sets the lastUpdateVersionTimestamp', () => {
const time = new Date().getTime()
store.dispatch(updateVersion())
expect(store.getState().lastUpdateVersionTimestamp).toBeGreaterThanOrEqual(time)
})
it('sets allowed slippage and deadline', () => {
store = createStore(reducer, { ...initialState, userDeadline: undefined, userSlippageTolerance: undefined })
store.dispatch(updateVersion())
expect(store.getState().userDeadline).toEqual(DEFAULT_DEADLINE_FROM_NOW)
expect(store.getState().userSlippageTolerance).toEqual(INITIAL_ALLOWED_SLIPPAGE)
})
})
})
import { INITIAL_ALLOWED_SLIPPAGE, DEFAULT_DEADLINE_FROM_NOW } from './../../constants/index' import { INITIAL_ALLOWED_SLIPPAGE, DEFAULT_DEADLINE_FROM_NOW } from '../../constants'
import { createReducer } from '@reduxjs/toolkit' import { createReducer } from '@reduxjs/toolkit'
import { import {
addSerializedPair, addSerializedPair,
...@@ -18,8 +18,9 @@ import { ...@@ -18,8 +18,9 @@ import {
const currentTimestamp = () => new Date().getTime() const currentTimestamp = () => new Date().getTime()
interface UserState { export interface UserState {
lastVersion: string // the timestamp of the last updateVersion action
lastUpdateVersionTimestamp?: number
userDarkMode: boolean | null // the user's choice for dark mode or light mode userDarkMode: boolean | null // the user's choice for dark mode or light mode
matchesDarkMode: boolean // whether the dark mode media query matches matchesDarkMode: boolean // whether the dark mode media query matches
...@@ -59,8 +60,7 @@ function pairKey(token0Address: string, token1Address: string) { ...@@ -59,8 +60,7 @@ function pairKey(token0Address: string, token1Address: string) {
return `${token0Address};${token1Address}` return `${token0Address};${token1Address}`
} }
const initialState: UserState = { export const initialState: UserState = {
lastVersion: '',
userDarkMode: null, userDarkMode: null,
matchesDarkMode: false, matchesDarkMode: false,
userExpertMode: false, userExpertMode: false,
...@@ -71,14 +71,9 @@ const initialState: UserState = { ...@@ -71,14 +71,9 @@ const initialState: UserState = {
timestamp: currentTimestamp() timestamp: currentTimestamp()
} }
const GIT_COMMIT_HASH: string | undefined = process.env.REACT_APP_GIT_COMMIT_HASH
export default createReducer(initialState, builder => export default createReducer(initialState, builder =>
builder builder
.addCase(updateVersion, state => { .addCase(updateVersion, state => {
if (GIT_COMMIT_HASH && state.lastVersion !== GIT_COMMIT_HASH) {
state.lastVersion = GIT_COMMIT_HASH
// slippage isnt being tracked in local storage, reset to default // slippage isnt being tracked in local storage, reset to default
if (typeof state.userSlippageTolerance !== 'number') { if (typeof state.userSlippageTolerance !== 'number') {
state.userSlippageTolerance = INITIAL_ALLOWED_SLIPPAGE state.userSlippageTolerance = INITIAL_ALLOWED_SLIPPAGE
...@@ -88,8 +83,8 @@ export default createReducer(initialState, builder => ...@@ -88,8 +83,8 @@ export default createReducer(initialState, builder =>
if (typeof state.userDeadline !== 'number') { if (typeof state.userDeadline !== 'number') {
state.userDeadline = DEFAULT_DEADLINE_FROM_NOW state.userDeadline = DEFAULT_DEADLINE_FROM_NOW
} }
}
state.timestamp = currentTimestamp() state.lastUpdateVersionTimestamp = currentTimestamp()
}) })
.addCase(updateUserDarkMode, (state, action) => { .addCase(updateUserDarkMode, (state, action) => {
state.userDarkMode = action.payload.userDarkMode state.userDarkMode = action.payload.userDarkMode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment