aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-11 08:56:04 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-11 08:56:04 +0200
commit34d4ca50834e256e62a5971c6dc7c39e9e78e9fc (patch)
treebcd98427355ec82d40266d23a493dcf3dc64034e /src
parent4d700aee6a9bc51fb0f5c1d92123975ee25645d1 (diff)
If a video is being watched and it has been watched before, then move it to the top of history
Diffstat (limited to 'src')
-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;