|
@@ -376,20 +376,28 @@ export async function content_FeaturedVideosSet(
|
|
|
.some(isSame(video.toString()))
|
|
|
)
|
|
|
|
|
|
+ // escape if no featured video needs to be added or removed
|
|
|
+ if (!toRemove.length && !toAdd.length) {
|
|
|
+ // emit log event
|
|
|
+ logger.info('Featured videos unchanged')
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// mark previously featured videos as not-featured
|
|
|
- for (let video of toRemove) {
|
|
|
- video.isFeatured = false;
|
|
|
+ await Promise.all(toRemove.map(async video => {
|
|
|
+ video.isFeatured = false
|
|
|
|
|
|
// set last update time
|
|
|
video.updatedAt = new Date(fixBlockTimestamp(event.blockTimestamp).toNumber())
|
|
|
|
|
|
await db.save<Video>(video)
|
|
|
- }
|
|
|
+ }))
|
|
|
|
|
|
// escape if no featured video needs to be added
|
|
|
- if (!toAdd) {
|
|
|
+ if (!toAdd.length) {
|
|
|
// emit log event
|
|
|
- logger.info('Featured videos unchanged')
|
|
|
+ logger.info('Some featured videos have been unset.', {videoIds: toRemove.map(item => item.id.toString())})
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -404,14 +412,14 @@ export async function content_FeaturedVideosSet(
|
|
|
}
|
|
|
|
|
|
// mark previously not-featured videos as featured
|
|
|
- for (let video of videosToAdd) {
|
|
|
- video.isFeatured = true;
|
|
|
+ await Promise.all(videosToAdd.map(async video => {
|
|
|
+ video.isFeatured = true
|
|
|
|
|
|
// set last update time
|
|
|
video.updatedAt = new Date(fixBlockTimestamp(event.blockTimestamp).toNumber())
|
|
|
|
|
|
await db.save<Video>(video)
|
|
|
- }
|
|
|
+ }))
|
|
|
|
|
|
// emit log event
|
|
|
logger.info('New featured videos have been set', {videoIds})
|