[gnome-documents] manager: emit a signal to remove the old item when replacing



commit 58a33193d022db35885f178fd3dec778cd232255
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Dec 14 08:02:34 2012 -0500

    manager: emit a signal to remove the old item when replacing
    
    When we replace an item with the same ID, first emit item-removed on the
    old one before emitting item-added, or we might find duplicates in the
    store.

 src/manager.js |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/manager.js b/src/manager.js
index 16d050c..114034c 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -57,6 +57,11 @@ const BaseManager = new Lang.Class({
 
     addItem: function(item) {
         item._manager = this;
+
+        let oldItem = this._items[item.id];
+        if (oldItem)
+            this.removeItem(oldItem);
+
         this._items[item.id] = item;
         this.emit('item-added', item);
     },



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