Skip to content

Commit 7221aae

Browse files
committed
Flush Benefit removals immediately (Joystream#375)
1 parent 0a25c54 commit 7221aae

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/mappings/content/commentsAndReactions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ async function processVideoReaction(
218218
--previousReactionTypeCounter.count
219219
// remove reaction
220220
videoReactionRepository.remove(existingReaction)
221+
await overlay.updateDatabase()
221222
return
222223
}
223224
// otherwise...
@@ -370,6 +371,7 @@ export async function processReactCommentMessage(
370371
--comment.reactionsCount
371372
// remove reaction
372373
commentReactionRepository.remove(existingReaction)
374+
await overlay.updateDatabase()
373375
} else {
374376
// new reaction
375377
const id = commentReactionEntityId({ memberId, commentId, reactionId })

src/mappings/content/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export async function deleteChannel(overlay: EntityManagerOverlay, channelId: bi
169169

170170
overlay.getRepository(BannedMember).remove(...bannedMembers)
171171
overlay.getRepository(Channel).remove(channelId.toString())
172+
await overlay.updateDatabase()
172173
// delete channel related notifications
173174
}
174175

@@ -204,6 +205,7 @@ export async function deleteVideo(overlay: EntityManagerOverlay, videoId: bigint
204205
}
205206
subtitlesRepository.remove(...subtitles)
206207
videoRepository.remove(video)
208+
await overlay.updateDatabase()
207209
}
208210

209211
export async function processNft(

src/mappings/token/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ export async function processTokenMetadata(
244244
token.description = metadata.description
245245
}
246246

247-
// remove all current bnefits
247+
// remove all current benefits
248248
const existingBenefit = await overlay
249249
.getRepository(Benefit)
250250
.getManyByRelation('tokenId', token.id)
251251
if (existingBenefit !== undefined) {
252252
overlay.getRepository(Benefit).remove(...existingBenefit)
253+
await overlay.updateDatabase()
253254
}
254255

255256
if (isSet(metadata.benefits)) {
@@ -302,6 +303,7 @@ export async function processTokenMetadata(
302303
}
303304
if (oldTrailer) {
304305
trailerVideoRepository.remove(oldTrailer)
306+
await overlay.updateDatabase()
305307
}
306308

307309
const id = overlay.getRepository(TrailerVideo).getNewEntityId()
@@ -316,6 +318,7 @@ export async function processTokenMetadata(
316318
const oldTrailer = await trailerVideoRepository.getOneByRelation('tokenId', token.id)
317319
if (oldTrailer) {
318320
trailerVideoRepository.remove(oldTrailer)
321+
await overlay.updateDatabase()
319322
}
320323
}
321324
}

0 commit comments

Comments
 (0)