aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/QuickMedia.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 18dd114..0586193 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -780,10 +780,12 @@ namespace QuickMedia {
}
- static bool watch_history_contains_id(const Json::Value &video_history_json, const char *id) {
+ static int watch_history_get_item_by_id(const Json::Value &video_history_json, const char *id) {
assert(video_history_json.isArray());
+ int index = -1;
for(const Json::Value &item : video_history_json) {
+ ++index;
if(!item.isObject())
continue;
@@ -792,10 +794,10 @@ namespace QuickMedia {
continue;
if(strcmp(id, id_json.asCString()) == 0)
- return true;
+ return index;
}
- return false;
+ return -1;
}
void Program::video_content_page() {
@@ -837,8 +839,11 @@ namespace QuickMedia {
Json::Value video_history_json = load_video_history_json(current_plugin);
- if(watch_history_contains_id(video_history_json, video_id.c_str()))
- return;
+ int existing_index = watch_history_get_item_by_id(video_history_json, video_id.c_str());
+ if(existing_index != -1) {
+ Json::Value removed;
+ video_history_json.removeIndex(existing_index, &removed);
+ }
Json::Value new_content_object(Json::objectValue);
new_content_object["id"] = video_id;