From b328e4c67f0f3dccc95de44805b92b6301ab956d Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Fri, 31 Mar 2023 22:55:02 +0200 Subject: [PATCH] feat: remove graph and graph data (#308) --- .../lib/adapters/in-memory-and-ipfs/index.ts | 38 +------------------ packages/ui/src/lib/components/graph.svelte | 24 ------------ packages/ui/src/lib/stores/tokens.ts | 11 ------ packages/ui/src/routes/dev/+page.svelte | 30 --------------- packages/ui/src/routes/profile/+page.svelte | 1 - 5 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 packages/ui/src/lib/components/graph.svelte diff --git a/packages/ui/src/lib/adapters/in-memory-and-ipfs/index.ts b/packages/ui/src/lib/adapters/in-memory-and-ipfs/index.ts index 207d773..5191245 100644 --- a/packages/ui/src/lib/adapters/in-memory-and-ipfs/index.ts +++ b/packages/ui/src/lib/adapters/in-memory-and-ipfs/index.ts @@ -15,7 +15,7 @@ import { VOTE_GO_PRICE, VOTE_REP_WIN, } from '$lib/constants' -import { tokens, type TokenData } from '$lib/stores/tokens' +import { tokens } from '$lib/stores/tokens' import { posts, type Post } from '$lib/stores/post' import { transaction, type TransactionRecord } from '$lib/stores/transaction' @@ -200,42 +200,6 @@ export class InMemoryAndIPFS implements Adapter { transaction.set({ transactions: storedTransactions }) tokens.set(storedTokens) - this.subscriptions.push( - tokens.subscribe((state) => { - let newState: TokenData | undefined = undefined - if ( - state.goHistoricalValues.length === 0 || - state.go !== state.goHistoricalValues[state.goHistoricalValues.length - 1].value - ) { - newState = { ...state } - newState.goHistoricalValues.push({ timestamp: Date.now(), value: state.go }) - } - if ( - state.repStakedHistoricalValues.length === 0 || - state.repStaked !== - state.repStakedHistoricalValues[state.repStakedHistoricalValues.length - 1].value - ) { - if (newState === undefined) { - newState = { ...state } - } - newState.repStakedHistoricalValues.push({ timestamp: Date.now(), value: state.repStaked }) - } - if ( - state.repTotalHistoricalValues.length === 0 || - state.repTotal !== - state.repTotalHistoricalValues[state.repTotalHistoricalValues.length - 1].value - ) { - if (newState === undefined) { - newState = { ...state } - } - newState.repTotalHistoricalValues.push({ timestamp: Date.now(), value: state.repTotal }) - } - if (newState !== undefined) { - tokens.update(() => state) - saveToLocalStorage('tokens', state) - } - }), - ) this.subscriptions.push( transaction.subscribe(({ transactions }) => { diff --git a/packages/ui/src/lib/components/graph.svelte b/packages/ui/src/lib/components/graph.svelte deleted file mode 100644 index 0cf0558..0000000 --- a/packages/ui/src/lib/components/graph.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - -
- x axis scale: {minX} - {maxX} - y axis scale: {minY} - {maxY} - values length: {values.length} -
- - diff --git a/packages/ui/src/lib/stores/tokens.ts b/packages/ui/src/lib/stores/tokens.ts index 6368012..035488a 100644 --- a/packages/ui/src/lib/stores/tokens.ts +++ b/packages/ui/src/lib/stores/tokens.ts @@ -1,19 +1,11 @@ import { DEFAULT_GO_AMOUNT } from '$lib/constants' import { writable, type Writable } from 'svelte/store' -interface TokenValues { - timestamp: number - value: number -} - export interface TokenData { go: number repTotal: number repStaked: number loading: boolean - goHistoricalValues: TokenValues[] - repStakedHistoricalValues: TokenValues[] - repTotalHistoricalValues: TokenValues[] epochDuration: number timeToEpoch: number } @@ -27,9 +19,6 @@ function createTokenStore(): TokenStore { repTotal: 55, repStaked: 0, loading: false, - goHistoricalValues: [], - repStakedHistoricalValues: [], - repTotalHistoricalValues: [], epochDuration, timeToEpoch: epochDuration - (Date.now() % epochDuration), }) diff --git a/packages/ui/src/routes/dev/+page.svelte b/packages/ui/src/routes/dev/+page.svelte index 6ecc9dc..1aea039 100644 --- a/packages/ui/src/routes/dev/+page.svelte +++ b/packages/ui/src/routes/dev/+page.svelte @@ -11,7 +11,6 @@ import Select from '$lib/components/select.svelte' import { saveToLocalStorage } from '$lib/utils' import { startNewEpoch } from '$lib/adapters/in-memory-and-ipfs' - import { formatDateAndTime } from '$lib/utils/format' let goTokenValue = $tokens.go.toFixed() let repTokenValue = $tokens.repTotal.toFixed() @@ -59,35 +58,6 @@