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

Добавить пагинацию #102

Closed
22 tasks done
azinit opened this issue Nov 22, 2020 · 2 comments · Fixed by #135
Closed
22 tasks done

Добавить пагинацию #102

azinit opened this issue Nov 22, 2020 · 2 comments · Fixed by #135
Assignees
Labels
enhancement New feature or request IMPORTANT Important and significant

Comments

@azinit
Copy link
Member

azinit commented Nov 22, 2020

@azinit azinit added this to the Backlog milestone Nov 22, 2020
@azinit azinit added the enhancement New feature or request label Nov 22, 2020
@azinit
Copy link
Member Author

azinit commented Nov 22, 2020

Ресурсы

cache: new InMemoryCache({
        typePolicies: {
            Query: {
                fields: {
                    search: relayStylePagination(),
                },
            },
        },
    }),
const { data, loading, fetchMore, error, refetch } = useSearchQuery({
        variables: {
            type: searchTypeEnum,
            query: searchQuery,
        },
        errorPolicy: "all",
        notifyOnNetworkStatusChange: true,
    });
...

    useEffect(() => {
        refetch({
            type: searchTypeEnum,
            query: searchQuery,
        });
        /* eslint-disable-next-line react-hooks/exhaustive-deps */
    }, [searchTypeEnum]);
    if (error) {
        console.error(`#${data?.search.pageInfo.startCursor}`, error);
    }

...
<div className="search-results__pages">
                <button
                    onClick={() => {
                        fetchMore({
                            variables: {
                                cursor: data?.search.pageInfo.endCursor,
                            },
                        });
                    }}
                >
                    Fetch more
                </button>
            </div>
query Search($query: String!, $type: SearchType!, $cursor: String) {
  search(query: $query, type: $type, first: 10, after: $cursor) {
    pageInfo {
      endCursor
      startCursor
      hasNextPage
      hasPreviousPage
    }
    edges {
      node {
        ...RepoFields
        ...UserFields
      }
    }
  }

@azinit
Copy link
Member Author

azinit commented Nov 25, 2020

image

@azinit azinit modified the milestones: Backlog, Спринт 2020_6 Nov 25, 2020
azinit added a commit that referenced this issue Nov 25, 2020
azinit added a commit that referenced this issue Nov 25, 2020
azinit added a commit that referenced this issue Nov 25, 2020
Feature/pagination search

- (#102) Добавление пагинации на странице поиска + легкий рефакторинг

![image](https://user-images.githubusercontent.com/42924400/100256825-4ff3c200-2f56-11eb-8996-3459594c858a.png)
@azinit azinit linked a pull request Nov 25, 2020 that will close this issue
azinit added a commit that referenced this issue Nov 25, 2020
Feature/pagination repo list

## ДИСКЛЕЙМЕР
Да, в github такая же долбанутая пагинация, но зато было откуда брать пример

Да и поддерживаемость ссылок надо было поддерживать между сайтами

## CHANGELOG
- (#102) Добавление пагинации для страницы пользователя (Список репозиториев)
- (#134) Добавлен лейбл с кол-вом элементов для repo-list

![image](https://user-images.githubusercontent.com/42924400/100276938-65c3b000-2f73-11eb-9431-126c4854f550.png)
@azinit azinit unpinned this issue Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request IMPORTANT Important and significant
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant