Skip to content

Commit

Permalink
fixed notifications for featured NFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
attemka committed Mar 19, 2024
1 parent b4ca873 commit 6d016c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server-extension/resolvers/AdminResolver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ export class AdminResolver {
export const setFeaturedNftsInner = async (em: EntityManager, featuredNftsIds: string[]) => {
let newNumberOfNftsFeatured = 0

const currentFeaturedNft = await em.find(OwnedNft, { where: { isFeatured: true } })
const currentFeaturedNftIds = currentFeaturedNft.map((nft) => nft.id)

await em
.createQueryBuilder()
.update<OwnedNft>(OwnedNft)
Expand All @@ -537,7 +540,9 @@ export const setFeaturedNftsInner = async (em: EntityManager, featuredNftsIds: s
where: { id: featuredNftId },
relations: { video: { channel: true } },
})
if (featuredNft?.video?.channel) {
const alreadyFeatured = currentFeaturedNftIds.includes(featuredNftId)
// this will avoid duplicated notifications if the nft was reselected as featured
if (!alreadyFeatured && featuredNft?.video?.channel) {
const notificationData = {
videoId: featuredNft.video.id,
videoTitle: parseVideoTitle(featuredNft.video),
Expand Down

0 comments on commit 6d016c0

Please sign in to comment.