Skip to content

Commit

Permalink
added isLatestCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
thesujai committed Jan 2, 2024
1 parent af2ab3d commit 7941f44
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion kolibri/plugins/device/assets/src/modules/manageContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7941f44

Please sign in to comment.