Commit ed0f59f6 authored by aleclofabbro's avatar aleclofabbro
Browse files

Merge branch 'fix/joined_communities_limit_var_and_restore_load_more_on_sidebar' into develop

parents bb7826c7 d8c58a8a
...@@ -13,7 +13,11 @@ import * as ApolloReactHooks from '@apollo/react-hooks'; ...@@ -13,7 +13,11 @@ import * as ApolloReactHooks from '@apollo/react-hooks';
export type MyCommunityFollowsQueryVariables = {}; export type MyCommunityFollowsQueryVariables = {
limit?: Types.Maybe<Types.Scalars['Int']>,
before?: Types.Maybe<Array<Types.Scalars['Cursor']>>,
after?: Types.Maybe<Array<Types.Scalars['Cursor']>>
};
export type MyCommunityFollowsQuery = ( export type MyCommunityFollowsQuery = (
...@@ -64,7 +68,7 @@ export const MyCommunityFollowsDataFragmentDoc = gql` ...@@ -64,7 +68,7 @@ export const MyCommunityFollowsDataFragmentDoc = gql`
fragment MyCommunityFollowsData on Me { fragment MyCommunityFollowsData on Me {
user { user {
id id
communityFollows { communityFollows(limit: $limit, before: $before, after: $after) {
totalCount totalCount
pageInfo { pageInfo {
...FullPageInfo ...FullPageInfo
...@@ -83,7 +87,7 @@ export const MyCommunityFollowsDataFragmentDoc = gql` ...@@ -83,7 +87,7 @@ export const MyCommunityFollowsDataFragmentDoc = gql`
${FullPageInfoFragmentDoc} ${FullPageInfoFragmentDoc}
${MyFollowedCommunityDataFragmentDoc}`; ${MyFollowedCommunityDataFragmentDoc}`;
export const MyCommunityFollowsDocument = gql` export const MyCommunityFollowsDocument = gql`
query myCommunityFollows { query myCommunityFollows($limit: Int, $before: [Cursor!], $after: [Cursor!]) {
me @connection(key: "myCommunityFollows") { me @connection(key: "myCommunityFollows") {
...MyCommunityFollowsData ...MyCommunityFollowsData
} }
...@@ -102,6 +106,9 @@ export const MyCommunityFollowsDocument = gql` ...@@ -102,6 +106,9 @@ export const MyCommunityFollowsDocument = gql`
* @example * @example
* const { data, loading, error } = useMyCommunityFollowsQuery({ * const { data, loading, error } = useMyCommunityFollowsQuery({
* variables: { * variables: {
* limit: // value for 'limit'
* before: // value for 'before'
* after: // value for 'after'
* }, * },
* }); * });
*/ */
......
query myCommunityFollows { query myCommunityFollows($limit:Int, $before:[Cursor!], $after:[Cursor!]){
me @connection(key: "myCommunityFollows"){ me @connection(key: "myCommunityFollows"){
...MyCommunityFollowsData ...MyCommunityFollowsData
} }
...@@ -8,7 +8,7 @@ query myCommunityFollows { ...@@ -8,7 +8,7 @@ query myCommunityFollows {
fragment MyCommunityFollowsData on Me { fragment MyCommunityFollowsData on Me {
user{ user{
id id
communityFollows{ communityFollows(limit:$limit, before:$before, after:$after) {
totalCount, totalCount,
pageInfo{ ...FullPageInfo } pageInfo{ ...FullPageInfo }
edges{ edges{
......
...@@ -3,16 +3,18 @@ import * as GQL from './myFollowedCommunities.generated'; ...@@ -3,16 +3,18 @@ import * as GQL from './myFollowedCommunities.generated';
import { usePage } from 'fe/lib/helpers/usePage'; import { usePage } from 'fe/lib/helpers/usePage';
// import { DEFAULT_PAGE_SIZE } from 'mn-constants'; // import { DEFAULT_PAGE_SIZE } from 'mn-constants';
const MY_JOINMED_LIST_LIMIT = 15; // TODO CONFIGURE
export const useMyFollowedCommunities = () => { export const useMyFollowedCommunities = () => {
const myFlwCommunitiesQ = GQL.useMyCommunityFollowsQuery({ const myFlwCommunitiesQ = GQL.useMyCommunityFollowsQuery({
variables: { limit: 10 } // FIXME variables: { limit: MY_JOINMED_LIST_LIMIT }
}); });
const myCommunityFollowsPage = usePage( const myCommunityFollowsPage = usePage(
myFlwCommunitiesQ.data?.me?.user.communityFollows, myFlwCommunitiesQ.data?.me?.user.communityFollows,
({ cursor, update }) => { ({ cursor, update }) => {
return myFlwCommunitiesQ.fetchMore({ return myFlwCommunitiesQ.fetchMore({
variables: { ...cursor, limit: 10 }, // FIXME CONFIGURE variables: { ...cursor, limit: MY_JOINMED_LIST_LIMIT },
updateQuery: (prev, { fetchMoreResult }) => { updateQuery: (prev, { fetchMoreResult }) => {
return fetchMoreResult?.me?.user?.communityFollows && return fetchMoreResult?.me?.user?.communityFollows &&
prev.me?.user?.communityFollows prev.me?.user?.communityFollows
......
...@@ -12,6 +12,7 @@ import Avatar from 'ui/elements/Avatar'; ...@@ -12,6 +12,7 @@ import Avatar from 'ui/elements/Avatar';
import { my_timeline, logo_small_url } from '../../../mn-constants'; import { my_timeline, logo_small_url } from '../../../mn-constants';
// const MnetLogo = require('static/img/logo-icon.png'); // const MnetLogo = require('static/img/logo-icon.png');
import { FormikHook } from 'ui/@types/types'; import { FormikHook } from 'ui/@types/types';
import { LoadMore } from '../Loadmore';
// import { LoadMore } from 'ui/modules/Loadmore'; // import { LoadMore } from 'ui/modules/Loadmore';
export enum Status { export enum Status {
...@@ -225,9 +226,9 @@ export const Sidebar: React.FC<Props> = props => { ...@@ -225,9 +226,9 @@ export const Sidebar: React.FC<Props> = props => {
</CommunityLink> </CommunityLink>
) )
)} )}
{/* {props.LoadMoreFormik && ( {props.LoadMoreFormik && (
<LoadMore LoadMoreFormik={props.LoadMoreFormik} /> <LoadMore LoadMoreFormik={props.LoadMoreFormik} />
)} */} )}
</Nav> </Nav>
</> </>
</SidebarOverflow> </SidebarOverflow>
......
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