Skip to content

Commit

Permalink
remove limit overwrites
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu committed Oct 9, 2023
1 parent 019995d commit 8c32dbb
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { mockProfileFragment, mockSearchProfilesResponse } from '@lens-protocol/
import { waitFor } from '@testing-library/react';

import { setupHookTestScenario } from '../../__helpers__/setupHookTestScenario';
import { DEFAULT_PAGINATED_QUERY_LIMIT } from '../../utils';
import { UseSearchProfilesArgs, useSearchProfiles } from '../useSearchProfiles';

describe(`Given the ${useSearchProfiles.name} hook`, () => {
Expand All @@ -16,7 +15,6 @@ describe(`Given the ${useSearchProfiles.name} hook`, () => {
mockSearchProfilesResponse({
variables: {
query,
limit: DEFAULT_PAGINATED_QUERY_LIMIT,
},
items: profiles,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { waitFor } from '@testing-library/react';

import { setupHookTestScenario } from '../../__helpers__/setupHookTestScenario';
import { DEFAULT_PAGINATED_QUERY_LIMIT } from '../../utils';
import { UseSearchPublicationsArgs, useSearchPublications } from '../useSearchPublications';

describe(`Given the ${useSearchPublications.name} hook`, () => {
Expand All @@ -32,10 +31,7 @@ describe(`Given the ${useSearchPublications.name} hook`, () => {

const { renderHook } = setupHookTestScenario([
mockSearchPublicationsResponse({
variables: {
...args,
limit: DEFAULT_PAGINATED_QUERY_LIMIT,
},
variables: args,
items: publications,
}),
]);
Expand Down
13 changes: 2 additions & 11 deletions packages/react/src/discovery/useSearchProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {

import { useLensApolloClient } from '../helpers/arguments';
import { PaginatedArgs, PaginatedReadResult, usePaginatedReadResult } from '../helpers/reads';
import { DEFAULT_PAGINATED_QUERY_LIMIT } from '../utils';

export type UseSearchProfilesArgs = PaginatedArgs<ProfileSearchRequest>;

Expand Down Expand Up @@ -38,19 +37,11 @@ export type UseSearchProfilesArgs = PaginatedArgs<ProfileSearchRequest>;
* }
* ```
*/
export function useSearchProfiles({
query,
where,
limit = DEFAULT_PAGINATED_QUERY_LIMIT,
}: UseSearchProfilesArgs): PaginatedReadResult<Profile[]> {
export function useSearchProfiles(args: UseSearchProfilesArgs): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useBaseSearchProfiles(
useLensApolloClient({
variables: {
query,
where,
limit,
},
variables: args,
}),
),
);
Expand Down
15 changes: 4 additions & 11 deletions packages/react/src/discovery/useSearchPublications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {

import { useLensApolloClient } from '../helpers/arguments';
import { PaginatedArgs, PaginatedReadResult, usePaginatedReadResult } from '../helpers/reads';
import { DEFAULT_PAGINATED_QUERY_LIMIT } from '../utils';

export type UseSearchPublicationsArgs = PaginatedArgs<PublicationSearchRequest>;

Expand Down Expand Up @@ -73,19 +72,13 @@ export type UseSearchPublicationsArgs = PaginatedArgs<PublicationSearchRequest>;
* }
* ```
*/
export function useSearchPublications({
query,
where,
limit = DEFAULT_PAGINATED_QUERY_LIMIT,
}: UseSearchPublicationsArgs): PaginatedReadResult<PrimaryPublication[]> {
export function useSearchPublications(
args: UseSearchPublicationsArgs,
): PaginatedReadResult<PrimaryPublication[]> {
return usePaginatedReadResult(
useBaseSearchPublications(
useLensApolloClient({
variables: {
query,
where,
limit,
},
variables: args,
}),
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LimitType } from '@lens-protocol/api-bindings';
import { mockProfileFragment, mockFollowersResponse } from '@lens-protocol/api-bindings/mocks';
import { mockProfileId } from '@lens-protocol/domain/mocks';
import { waitFor } from '@testing-library/react';
Expand All @@ -17,7 +16,6 @@ describe(`Given the ${useProfileFollowers.name} hook`, () => {
mockFollowersResponse({
variables: {
of: profileId,
limit: LimitType.Ten,
},
items: profiles,
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LimitType } from '@lens-protocol/api-bindings';
import { mockProfileFragment, mockFollowingResponse } from '@lens-protocol/api-bindings/mocks';
import { mockProfileId } from '@lens-protocol/domain/mocks';
import { waitFor } from '@testing-library/react';
Expand All @@ -17,7 +16,6 @@ describe(`Given the ${useProfileFollowing.name} hook`, () => {
mockFollowingResponse({
variables: {
for: profileId,
limit: LimitType.Ten,
},
items: profiles,
}),
Expand Down
5 changes: 1 addition & 4 deletions packages/react/src/profile/__tests__/useProfiles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LimitType } from '@lens-protocol/api-bindings';
import {
mockCursor,
mockPaginatedResultInfo,
Expand All @@ -24,7 +23,6 @@ describe(`Given the ${useProfiles.name} hook`, () => {
where: {
ownedBy: [evmAddress],
},
limit: LimitType.Ten,
},
items: profiles,
}),
Expand All @@ -50,7 +48,6 @@ describe(`Given the ${useProfiles.name} hook`, () => {
where: {
ownedBy: [evmAddress],
},
limit: LimitType.Ten,
},
items: profiles,
info: initialPageInfo,
Expand All @@ -61,7 +58,7 @@ describe(`Given the ${useProfiles.name} hook`, () => {
where: {
ownedBy: [evmAddress],
},
limit: LimitType.Ten,

cursor: initialPageInfo.prev,
},
items: [mockProfileFragment()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LimitType } from '@lens-protocol/api-bindings';
import {
mockProfileFragment,
mockProfileRecommendationsResponse,
Expand All @@ -20,7 +19,6 @@ describe(`Given the ${useRecommendedProfiles.name} hook`, () => {
mockProfileRecommendationsResponse({
variables: {
for: profileId,
limit: LimitType.Ten,
},
items: profiles,
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LimitType } from '@lens-protocol/api-bindings';
import {
mockProfileFragment,
mockWhoActedOnPublicationResponse,
Expand All @@ -23,7 +22,6 @@ describe(`Given the ${useWhoActedOnPublication.name} hook`, () => {
mockWhoActedOnPublicationResponse({
variables: {
on: publicationId,
limit: LimitType.Ten,
},
items: profiles,
}),
Expand Down
11 changes: 2 additions & 9 deletions packages/react/src/profile/useProfileFollowers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
LimitType,
Profile,
FollowersRequest,
useFollowers as useFollowersHook,
Expand All @@ -26,17 +25,11 @@ export type UseProfileFollowersArgs = PaginatedArgs<FollowersRequest>;
* });
* ```
*/
export function useProfileFollowers({
of,
limit = LimitType.Ten,
}: UseProfileFollowersArgs): PaginatedReadResult<Profile[]> {
export function useProfileFollowers(args: UseProfileFollowersArgs): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useFollowersHook(
useLensApolloClient({
variables: {
of,
limit,
},
variables: args,
}),
),
);
Expand Down
11 changes: 2 additions & 9 deletions packages/react/src/profile/useProfileFollowing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
LimitType,
Profile,
FollowingRequest,
useFollowing as useFollowingHook,
Expand All @@ -26,17 +25,11 @@ export type UseProfileFollowingArgs = PaginatedArgs<FollowingRequest>;
* });
* ```
*/
export function useProfileFollowing({
for: forId,
limit = LimitType.Ten,
}: UseProfileFollowingArgs): PaginatedReadResult<Profile[]> {
export function useProfileFollowing(args: UseProfileFollowingArgs): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useFollowingHook(
useLensApolloClient({
variables: {
for: forId,
limit,
},
variables: args,
}),
),
);
Expand Down
11 changes: 2 additions & 9 deletions packages/react/src/profile/useProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {

import { useLensApolloClient } from '../helpers/arguments';
import { PaginatedArgs, PaginatedReadResult, usePaginatedReadResult } from '../helpers/reads';
import { DEFAULT_PAGINATED_QUERY_LIMIT } from '../utils';

/**
* {@link useProfiles} hook arguments
Expand Down Expand Up @@ -79,17 +78,11 @@ export type UseProfilesArgs = PaginatedArgs<ProfilesRequest>;
* });
* ```
*/
export function useProfiles({
where,
limit = DEFAULT_PAGINATED_QUERY_LIMIT,
}: UseProfilesArgs): PaginatedReadResult<Profile[]> {
export function useProfiles(args: UseProfilesArgs): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useProfilesHook(
useLensApolloClient({
variables: {
where,
limit,
},
variables: args,
}),
),
);
Expand Down
17 changes: 4 additions & 13 deletions packages/react/src/profile/useRecommendedProfiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
LimitType,
Profile,
ProfileRecommendationsRequest,
useProfileRecommendations as useProfileRecommendationsHook,
Expand All @@ -26,21 +25,13 @@ export type UseRecommendedProfilesArgs = PaginatedArgs<ProfileRecommendationsReq
* });
* ```
*/
export function useRecommendedProfiles({
for: forId,
disableML,
shuffle,
limit = LimitType.Ten,
}: UseRecommendedProfilesArgs): PaginatedReadResult<Profile[]> {
export function useRecommendedProfiles(
args: UseRecommendedProfilesArgs,
): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useProfileRecommendationsHook(
useLensApolloClient({
variables: {
for: forId,
disableML,
shuffle,
limit,
},
variables: args,
}),
),
);
Expand Down
15 changes: 4 additions & 11 deletions packages/react/src/profile/useWhoActedOnPublication.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
LimitType,
Profile,
useWhoActedOnPublication as useWhoActedOnPublicationHook,
WhoActedOnPublicationRequest,
Expand All @@ -26,19 +25,13 @@ export type UseWhoActedOnPublicationArgs = PaginatedArgs<WhoActedOnPublicationRe
* });
* ```
*/
export function useWhoActedOnPublication({
on,
where,
limit = LimitType.Ten,
}: UseWhoActedOnPublicationArgs): PaginatedReadResult<Profile[]> {
export function useWhoActedOnPublication(
args: UseWhoActedOnPublicationArgs,
): PaginatedReadResult<Profile[]> {
return usePaginatedReadResult(
useWhoActedOnPublicationHook(
useLensApolloClient({
variables: {
on,
where,
limit,
},
variables: args,
}),
),
);
Expand Down
11 changes: 3 additions & 8 deletions packages/react/src/publication/__tests__/usePublications.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LimitType, PublicationsOrderByType } from '@lens-protocol/api-bindings';
import { LimitType } from '@lens-protocol/api-bindings';
import {
mockCursor,
mockPublicationsResponse,
Expand All @@ -24,8 +24,6 @@ describe(`Given the ${usePublications.name} hook`, () => {
where: {
actedBy: profileId,
},
orderBy: PublicationsOrderByType.Latest,
limit: LimitType.Ten,
},
items: publications,
}),
Expand All @@ -49,7 +47,7 @@ describe(`Given the ${usePublications.name} hook`, () => {
where: {
actedBy: profileId,
},
orderBy: PublicationsOrderByType.Latest,

limit: LimitType.Fifty,
},
items: publications,
Expand Down Expand Up @@ -77,8 +75,6 @@ describe(`Given the ${usePublications.name} hook`, () => {
where: {
from: [profileId],
},
orderBy: PublicationsOrderByType.Latest,
limit: LimitType.Ten,
},
items: publications,
info: initialPageInfo,
Expand All @@ -89,8 +85,7 @@ describe(`Given the ${usePublications.name} hook`, () => {
where: {
from: [profileId],
},
orderBy: PublicationsOrderByType.Latest,
limit: LimitType.Ten,

cursor: initialPageInfo.prev,
},
items: [mockPostFragment()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ describe(`Given the ${useWhoReactedToPublication.name} hook`, () => {

const { renderHook } = setupHookTestScenario([
mockWhoReactedToPublicationResponse({
variables: {
...args,
},
variables: args,
items: profileReactions,
}),
]);
Expand Down
Loading

0 comments on commit 8c32dbb

Please sign in to comment.