From 7941f440b96c66ae4be122ba9d2805f3a0da9c01 Mon Sep 17 00:00:00 2001 From: Sujai Kumar Gupta Date: Thu, 28 Dec 2023 15:49:20 +0530 Subject: [PATCH] added isLatestCheck --- .../assets/src/modules/manageContent/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kolibri/plugins/device/assets/src/modules/manageContent/index.js b/kolibri/plugins/device/assets/src/modules/manageContent/index.js index e9dc3b15ce..00da52d4ad 100644 --- a/kolibri/plugins/device/assets/src/modules/manageContent/index.js +++ b/kolibri/plugins/device/assets/src/modules/manageContent/index.js @@ -49,12 +49,24 @@ export default { return channels.map(channel => { const taskIndex = findLastIndex(getters.managedTasks, task => { + const isLatest = task => { + const tasksWithSameChannelId = getters.managedTasks.filter( + t => t.extra_metadata.channel_id === channel.id && t.status === TaskStatuses.COMPLETED + ); + const maxScheduledDatetime = tasksWithSameChannelId.reduce( + (max, current) => + current.scheduled_datetime > max ? current.scheduled_datetime : max, + tasksWithSameChannelId[0].scheduled_datetime + ); + return task.scheduled_datetime === maxScheduledDatetime; + }; return ( ![TaskTypes.DISKCONTENTEXPORT, TaskTypes.DISKEXPORT, TaskTypes.DELETECHANNEL].includes( task.type ) && task.extra_metadata.channel_id === channel.id && - task.status === TaskStatuses.COMPLETED + task.status === TaskStatuses.COMPLETED && + isLatest(task) // corresponds to latest changes on channel ); }); return {