[grilo-plugins/wip/hadess/dup-bookmarks-added] bookmarks: Fix duplicate GRL_CONTENT_ADDED notifications



commit 6158eb5ab144099dc96f9fbfec0744c9722b3134
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Feb 7 02:07:24 2019 +0100

    bookmarks: Fix duplicate GRL_CONTENT_ADDED notifications
    
    The bookmarks source only ever knew how to send GRL_CONTENT_ADDED
    notifications, even when modifying a new resource to the database.
    Track whether the resource is new to send the correct notification.
    
    This was causing saved streams in Videos to appear duplicated.

 src/bookmarks/grl-bookmarks.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/bookmarks/grl-bookmarks.c b/src/bookmarks/grl-bookmarks.c
index b83b4e3..9e8db9b 100644
--- a/src/bookmarks/grl-bookmarks.c
+++ b/src/bookmarks/grl-bookmarks.c
@@ -686,6 +686,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
   gchar *str_id;
   GError *local_error = NULL;
   gboolean ret;
+  gboolean is_new_bookmark = FALSE;
 
   GRL_DEBUG ("store_bookmark");
 
@@ -722,6 +723,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
                              "parent", parent_id,
                              "type", type,
                              NULL);
+    is_new_bookmark = TRUE;
   }
 
   if (type == BOOKMARK_TYPE_STREAM) {
@@ -780,7 +782,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
   if (bookmarks_source->priv->notify_changes) {
     grl_source_notify_change (GRL_SOURCE (bookmarks_source),
                               bookmark,
-                              GRL_CONTENT_ADDED,
+                              is_new_bookmark ? GRL_CONTENT_ADDED : GRL_CONTENT_CHANGED,
                               FALSE);
   }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]