From 795435ff4bfb24ea283ba893a446de93aa980bdf Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 20 May 2024 14:00:40 -0400 Subject: [PATCH] Fix duplicate bookmarked items bug (#383) * Fix duplicate bookmarked items bug * Add a check on task state --- CHANGELOG.md | 6 ++++++ .../src/components/VideoFeed/VideoRowList.bs | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24b3ff93..5efe0818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- A bug where bookmarked channels can be duplicated + ## [0.23.5] - 2024-05-19 ### Fixed diff --git a/playlet-lib/src/components/VideoFeed/VideoRowList.bs b/playlet-lib/src/components/VideoFeed/VideoRowList.bs index 6404db4a..c4721b17 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowList.bs +++ b/playlet-lib/src/components/VideoFeed/VideoRowList.bs @@ -222,13 +222,13 @@ function InitContent() as void node: m.top feeds: m.top.feeds }, OnVideoRowListContentTaskResult) - m.pendingLoadTasks[task.id] = task + m.pendingLoadTasks[task.id] = { task: task } end function function CancelCurrentTasks() pendingLoadTasks = m.pendingLoadTasks for each id in pendingLoadTasks - task = pendingLoadTasks[id] + task = pendingLoadTasks[id].task task.cancel = true end for m.pendingLoadTasks = {} @@ -287,7 +287,16 @@ function GetRowsToLoad() as object return subContentNodes end function -function LoadRowContent(contentNode as object) +function LoadRowContent(contentNode as object) as void + ' Do not spin up multiple tasks for the same content node + for each id in m.pendingLoadTasks + pendingTask = m.pendingLoadTasks[id] + if contentNode.isSameNode(pendingTask.content) and pendingTask.task.state = "run" + LogInfo("Row content already loading:", contentNode.title) + return + end if + end for + LogInfo("Loading row content:", contentNode.title) contentNode.loadState = FeedLoadState.Loading @@ -296,7 +305,7 @@ function LoadRowContent(contentNode as object) feedContentNode: contentNode invidious: m.invidious }, OnVideoRowListRowContentTaskResult) - m.pendingLoadTasks[task.id] = task + m.pendingLoadTasks[task.id] = { task: task, content: contentNode } end function function OnVideoRowListRowContentTaskResult(output as object) as void