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

Release react 2.0.0 alpha.35 #871

Merged
merged 5 commits into from
Mar 4, 2024
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
9 changes: 9 additions & 0 deletions .changeset/gold-ways-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@lens-protocol/api-bindings": minor
"@lens-protocol/domain": minor
"@lens-protocol/react": minor
"@lens-protocol/react-native": minor
"@lens-protocol/react-web": minor
---

**feat:** added `useRecommendProfileToggle` hook
7 changes: 7 additions & 0 deletions .changeset/green-ligers-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lens-protocol/react": patch
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
---

**fix:** useUpdateProfileManagers preconditions logic when approving signless
5 changes: 5 additions & 0 deletions .changeset/khaki-students-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lens-protocol/client": patch
---

**fix:** adds missing `lensPublicActProxyOnchainSigNonce` field to `UserSigNoncesFragment`
4 changes: 4 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@
"giant-games-type",
"gold-dolphins-pump",
"gold-radios-hunt",
"gold-ways-float",
"gold-wombats-tell",
"good-insects-compete",
"gorgeous-pigs-kneel",
"gorgeous-rice-trade",
"green-ligers-flow",
"grumpy-bugs-sip",
"grumpy-coats-scream",
"happy-donuts-boil",
Expand All @@ -102,6 +104,7 @@
"hot-eels-divide",
"hot-hornets-drum",
"itchy-mails-shout",
"khaki-students-pump",
"large-cars-know",
"large-glasses-grin",
"late-clocks-rhyme",
Expand Down Expand Up @@ -186,6 +189,7 @@
"swift-hornets-camp",
"swift-readers-compare",
"tall-gorillas-build",
"tall-penguins-ring",
"tame-icons-leave",
"tame-kiwis-own",
"tame-starfishes-prove",
Expand Down
7 changes: 7 additions & 0 deletions .changeset/tall-penguins-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lens-protocol/react": patch
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
---

**fix:** nonce management for link/unlink handles and unfollow profile
2 changes: 2 additions & 0 deletions examples/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
UseProfileManagers,
UseProfiles,
UseProfilesManaged,
UseRecommendProfileToggle,
UseReportProfile,
UseSetProfileMetadata,
UseUpdateFollowPolicy,
Expand Down Expand Up @@ -144,6 +145,7 @@ export function App() {
<Route path="useBlockedProfiles" element={<UseBlockedProfiles />} />
<Route path="useLastLoggedInProfile" element={<UseLastLoggedInProfile />} />
<Route path="useReportProfile" element={<UseReportProfile />} />
<Route path="useRecommendProfileToggle" element={<UseRecommendProfileToggle />} />
</Route>

<Route path="/discovery">
Expand Down
5 changes: 5 additions & 0 deletions examples/web/src/profiles/ProfilesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ const profileHooks = [
description: 'Report a profile.',
path: '/profiles/useReportProfile',
},
{
label: 'useRecommendProfileToggle',
description: 'Recommend a profile.',
path: '/profiles/useRecommendProfileToggle',
},
];

export function ProfilesPage() {
Expand Down
47 changes: 47 additions & 0 deletions examples/web/src/profiles/UseRecommendProfileToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Profile, useExploreProfiles, useRecommendProfileToggle } from '@lens-protocol/react-web';

import { RequireProfileSession } from '../components/auth';
import { ErrorMessage } from '../components/error/ErrorMessage';
import { Loading } from '../components/loading/Loading';
import { ProfileCard } from './components/ProfileCard';

function ProfileRecommendation({ profile }: { profile: Profile }) {
const { execute: toggle, loading } = useRecommendProfileToggle();

return (
<ProfileCard profile={profile}>
<button onClick={() => toggle({ profile })} disabled={loading}>
{profile.peerToPeerRecommendedByMe ? `Remove recommendation` : `Recommend`}
</button>
</ProfileCard>
);
}

function UseRecommendProfileToggleInner() {
const { data: profiles, error, loading } = useExploreProfiles();

if (loading) return <Loading />;
if (error) return <ErrorMessage error={error} />;

return (
<div>
{profiles.map((profile) => (
<ProfileRecommendation key={profile.id} profile={profile} />
))}
</div>
);
}

export function UseRecommendProfileToggle() {
return (
<div>
<h1>
<code>useRecommendProfileToggle</code>
</h1>

<RequireProfileSession message="Log in to view this example.">
<UseRecommendProfileToggleInner />
</RequireProfileSession>
</div>
);
}
1 change: 1 addition & 0 deletions examples/web/src/profiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './UseProfileFollowing';
export * from './UseProfileManagers';
export * from './UseProfiles';
export * from './UseProfilesManaged';
export * from './UseRecommendProfileToggle';
export * from './UseReportProfile';
export * from './UseSetProfileMetadata';
export * from './UseUpdateFollowPolicy';
Expand Down
11 changes: 11 additions & 0 deletions packages/api-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @lens-protocol/api-bindings

## 0.11.0-alpha.31

### Minor Changes

- 8869b5819: **feat:** added `useRecommendProfileToggle` hook

### Patch Changes

- Updated dependencies [8869b5819]
- @lens-protocol/[email protected]

## 0.11.0-alpha.30

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/api-bindings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lens-protocol/api-bindings",
"version": "0.11.0-alpha.30",
"version": "0.11.0-alpha.31",
"description": "Graphql fragments, react hooks, typescript types of lens API.",
"repository": {
"directory": "packages/api-bindings",
Expand Down
2 changes: 2 additions & 0 deletions packages/api-bindings/src/apollo/cache/createTypePolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export function createTypePolicies(): StrictTypedTypePolicies & InheritedTypePol
mutualFollowers: createMutualFollowersFieldPolicy(),
profileActionHistory: createProfileActionHistoryFieldPolicy(),
profileRecommendations: createProfileRecommendationsFieldPolicy(),
// TODO: investigate correct usage of cache redirect
// profile: createProfileFieldPolicy() as FieldPolicy<unknown>,
profiles: createProfilesFieldPolicy(),
publication: createPublicationFieldPolicy() as FieldPolicy<unknown>,
publications: createPublicationsFieldPolicy(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { FieldFunctionOptions, FieldPolicy, Reference } from '@apollo/client';

import { Profile, ProfileRequest } from '../../../lens';

// this function is not in use
// TODO: investigate correct usage of cache redirect
export function createProfileFieldPolicy(): FieldPolicy<
Profile,
Profile,
Reference,
FieldFunctionOptions<{ request: ProfileRequest }>
> {
return {
read(_, { args, toReference, canRead }) {
if (!args) {
return undefined;
}

if (args.request?.forProfileId) {
const ref = toReference({
__typename: 'Profile',
id: args.request.forProfileId,
});

if (canRead(ref)) {
return ref;
}
}

return undefined;
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './createFollowingFieldPolicy';
export * from './createMutualFollowersFieldPolicy';
export * from './createProfileActionHistoryFieldPolicy';
export * from './createProfileRecommendationsFieldPolicy';
export * from './createProfileFieldPolicy';
export * from './createProfilesFieldPolicy';
export * from './createPublicationFieldPolicy';
export * from './createPublicationsFieldPolicy';
Expand Down
1 change: 1 addition & 0 deletions packages/api-bindings/src/lens/__helpers__/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function mockProfileFragment(overrides?: Partial<gql.Profile>): gql.Profi
metadata: null,
invitedBy: null,
stats: mockProfileStatsFragment(),
peerToPeerRecommendedByMe: false,

...overrides,
__typename: 'Profile',
Expand Down
16 changes: 16 additions & 0 deletions packages/api-bindings/src/lens/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ fragment ProfileFields on Profile {
stats(request: { forApps: $statsFor }) {
...ProfileStats
}
peerToPeerRecommendedByMe
}

fragment Profile on Profile {
Expand Down Expand Up @@ -1496,6 +1497,21 @@ fragment LiveStreamMetadataV3 on LiveStreamMetadataV3 {
}

# publication fragments
fragment AnyPublicationInternal on AnyPublication {
... on Post {
...Post
}
... on Comment {
...Comment
}
... on Mirror {
...Mirror
}
... on Quote {
...Quote
}
}

fragment PublicationStats on PublicationStats {
__typename
id
Expand Down
Loading
Loading