-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import { getNextPageParam, select } from './utils'; | ||
|
||
enum OwnerFilter { | ||
All = 'all', | ||
User = 'user', | ||
} | ||
|
||
export { OwnerFilter }; | ||
// there's a problem with return type of select if those options are destructured to useInfiniteQuery, | ||
// therefore a little bit of boilerplate is needed. need to figure it out | ||
const INFINITE_QUERY = { | ||
INITIAL_PAGE_PARAM: 0, | ||
GET_NEXT_PAGE_PARAM: getNextPageParam, | ||
SELECT: select, | ||
}; | ||
|
||
export { OwnerFilter, INFINITE_QUERY }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
import { NodeSection } from '@/entities/node'; | ||
import { NODES_API_URL } from '@/shared/config'; | ||
import { fetchCode, fetchCodes, addCodeName } from './code'; | ||
import { fetchProgram, fetchPrograms, addProgramName } from './program'; | ||
|
||
import { fetchTestBalance } from './balance'; | ||
import { fetchMessage, fetchMessages } from './message'; | ||
import { fetchMetadata, addMetadata } from './metadata'; | ||
import { addState, fetchStates, fetchState } from './state'; | ||
import { PaginationParameters, PaginationResponse } from './types'; | ||
import { INFINITE_QUERY } from './consts'; | ||
|
||
const getNodes = () => fetch(NODES_API_URL).then((result) => result.json() as unknown as NodeSection[]); | ||
|
||
export { | ||
getNodes, | ||
fetchProgram, | ||
addProgramName, | ||
fetchPrograms, | ||
addMetadata, | ||
addCodeName, | ||
fetchMetadata, | ||
addState, | ||
fetchStates, | ||
fetchState, | ||
fetchCode as getCode, | ||
fetchCodes as getCodes, | ||
fetchMessage as getMessage, | ||
fetchMessages as getMessages, | ||
fetchTestBalance as getTestBalance, | ||
}; | ||
export { INFINITE_QUERY, getNodes, addMetadata, fetchMetadata, fetchTestBalance as getTestBalance }; | ||
|
||
export type { PaginationParameters, PaginationResponse }; |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
type PaginationModel = { | ||
publicKeyRaw?: string | null; | ||
source?: string | null; | ||
destination?: string | null; | ||
type PaginationParameters = { | ||
limit?: number; | ||
offset?: number; | ||
type?: string; | ||
query?: string; | ||
}; | ||
|
||
export type { PaginationModel }; | ||
type PaginationResponse<T> = { | ||
result: T[]; | ||
count: number; | ||
}; | ||
|
||
export type { PaginationParameters, PaginationResponse }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DEFAULT_LIMIT } from '@/shared/config'; | ||
|
||
import { PaginationResponse } from './types'; | ||
|
||
const getNextPageParam = <T>({ result, count }: PaginationResponse<T>, allPages: PaginationResponse<T>[]) => { | ||
const lastPageCount = result.length; | ||
const fetchedCount = (allPages.length - 1) * DEFAULT_LIMIT + lastPageCount; | ||
|
||
return fetchedCount < count ? fetchedCount : undefined; | ||
}; | ||
|
||
const select = <T>({ pages }: { pages: PaginationResponse<T>[] }) => ({ | ||
result: pages.flatMap((page) => page.result), | ||
count: pages[0].count, | ||
}); | ||
|
||
export { getNextPageParam, select }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { createContext } from 'react'; | ||
|
||
import { IChainBlock } from '@/entities/chainBlock'; | ||
import { RecentBlock } from '@/features/recentBlocks'; | ||
|
||
const BlocksContext = createContext<IChainBlock[]>([]); | ||
const BlocksContext = createContext<RecentBlock[]>([]); | ||
|
||
export { BlocksContext }; |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.