Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

257 provide indication to user in case loading of nfts is taking time in collection view #261

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const NftCollectionPageComponent: FC<INftCollectionPageComponent> = ({
currentCollection,
currentCollectionTotal,
currentCollectionStatus,
currentCollectionMetadata
currentCollectionMetadata,
currentCollectionNextPageStatus
} = useAppSelector((store) => store.tokens);

const { width } = useWindowDimensions();
Expand Down Expand Up @@ -781,7 +782,7 @@ const NftCollectionPageComponent: FC<INftCollectionPageComponent> = ({
</div>
)}
</div>
{isLoading && (
{currentCollectionNextPageStatus && (
<div className="progress-token">
<CircularProgress
style={{
Expand Down
12 changes: 12 additions & 0 deletions rair-front/src/redux/tokenSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface TokensState {
currentCollectionStatus: dataStatuses;
currentCollectionTotal: number;
currentCollection: { [index: string]: CollectionTokens };
currentCollectionNextPageStatus: boolean;
currentCollectionMetadata: MetadataForCollection;
currentCollectionMetadataStatus: dataStatuses;
itemsPerPage: number;
Expand All @@ -110,6 +111,7 @@ const initialState: TokensState = {
currentCollectionStatus: dataStatuses.Uninitialized,
currentCollectionTotal: 0,
currentCollection: {},
currentCollectionNextPageStatus: false,
currentCollectionParams: undefined,
// Collection contract data
currentCollectionMetadataStatus: dataStatuses.Uninitialized,
Expand Down Expand Up @@ -314,6 +316,7 @@ export const tokenSlice = createSlice({
state.currentCollectionStatus = dataStatuses.Uninitialized;
state.currentCollectionTotal = 0;
state.currentCollection = {};
state.currentCollectionNextPageStatus = false;
state.currentCollectionMetadataStatus = dataStatuses.Uninitialized;
state.currentCollectionMetadata = {};
state.currentCollectionParams = undefined;
Expand Down Expand Up @@ -360,6 +363,10 @@ export const tokenSlice = createSlice({
})

// Reuse collection data for next page
.addCase(loadNextCollectionPage.pending, (state) => {
state.currentCollectionNextPageStatus = true;
})

.addCase(
loadNextCollectionPage.fulfilled,
(state, action: PayloadAction<GetCollectionResponse | undefined>) => {
Expand All @@ -368,10 +375,15 @@ export const tokenSlice = createSlice({
state.currentCollection[token.uniqueIndexInContract.toString()] =
token;
});
state.currentCollectionNextPageStatus = false;
}
}
)

.addCase(loadNextCollectionPage.rejected, (state) => {
state.currentCollectionNextPageStatus = false;
})

// Load metadata for collection
.addCase(loadCollectionMetadata.pending, (state) => {
state.currentCollectionMetadataStatus = dataStatuses.Loading;
Expand Down