-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create profile & reactions (#516)
- Loading branch information
1 parent
063dc9c
commit 5425cf4
Showing
15 changed files
with
364 additions
and
186 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { LensClient, development } from "@lens-protocol/client"; | ||
|
||
async function main() { | ||
const lensClient = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
// add interests | ||
await lensClient.profile.addInterests({ | ||
interests: ["TECHNOLOGY", "HEALTH_FITNESS__EXERCISE"], | ||
}); | ||
|
||
// fetch all interests | ||
const { interests } = await lensClient.profile.fetch({ | ||
profileId: "PROFILE_ID", | ||
}); | ||
|
||
console.log(`Profile interests`, interests); | ||
|
||
// remove interests | ||
await lensClient.profile.removeInterests({ | ||
interests: ["HEALTH_FITNESS__EXERCISE"], | ||
}); | ||
} | ||
|
||
main(); |
33 changes: 33 additions & 0 deletions
33
examples/node/scripts/publication/reactions/addReaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { LensClient, PublicationReactionType, development } from "@lens-protocol/client"; | ||
|
||
async function main() { | ||
const lensClient = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
const feedResult = await lensClient.feed.fetch({ | ||
where: { | ||
for: "PROFILE_ID", | ||
}, | ||
limit: 20, | ||
}); | ||
|
||
const feedItems = feedResult.unwrap().items; | ||
|
||
// find first item without a reaction | ||
const feedItem = feedItems.find((item) => !item.reactions); | ||
|
||
if (!feedItem) { | ||
throw new Error(`You reacted to all feed items`); | ||
} | ||
|
||
// add reaction | ||
await lensClient.publication.reactions.add({ | ||
for: "PUBLICATION_ID", | ||
reaction: PublicationReactionType.Upvote, | ||
}); | ||
|
||
console.log(`You added a reaction to ${feedItem.root.id}`); | ||
} | ||
|
||
main(); |
33 changes: 33 additions & 0 deletions
33
examples/node/scripts/publication/reactions/removeReaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { LensClient, PublicationReactionType, development } from "@lens-protocol/client"; | ||
|
||
async function main() { | ||
const lensClient = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
const feedResult = await lensClient.feed.fetch({ | ||
where: { | ||
for: "PROFILE_ID", | ||
}, | ||
limit: 20, | ||
}); | ||
|
||
const feedItems = feedResult.unwrap().items; | ||
|
||
// find first item with a reaction | ||
const feedItem = feedItems.find((item) => item.reactions); | ||
|
||
if (!feedItem) { | ||
throw new Error(`You haven't reacted to anything`); | ||
} | ||
|
||
// add reaction | ||
await lensClient.publication.reactions.remove({ | ||
for: "PUBLICATION_ID", | ||
reaction: PublicationReactionType.Upvote, | ||
}); | ||
|
||
console.log(`You remove a reaction from ${feedItem.root.id}`); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
ExplorePublicationsOrderByType, | ||
LensClient, | ||
PublicationReactionType, | ||
development, | ||
} from "@lens-protocol/client"; | ||
|
||
async function main() { | ||
const lensClient = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
const profilesWhoReacted = await lensClient.publication.reactions.fetch({ | ||
for: "PUBLICATION_ID", | ||
limit: 20, | ||
}); | ||
|
||
console.log( | ||
`Profiles who reacted to publication: ${JSON.stringify(profilesWhoReacted, null, 2)}` | ||
); | ||
|
||
await lensClient.publication.reactions.add({ | ||
for: "PUBLICATION_ID", | ||
reaction: PublicationReactionType.Upvote, | ||
}); | ||
|
||
const profilesWhoReactedAfterUpvote = await lensClient.publication.reactions.fetch({ | ||
for: "PUBLICATION_ID", | ||
limit: 20, | ||
}); | ||
|
||
console.log( | ||
`Profiles who reacted to publication after upvote: ${JSON.stringify( | ||
profilesWhoReactedAfterUpvote, | ||
null, | ||
2 | ||
)}` | ||
); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.