Q:

Duplicated content from Firebase query after updating it

I'm doing an application about shared notes using Swift and Firebase.
Once I load the view where the notes are displayed, a tableview gets filled with the notes information on each row:

To do so, first I do a query to find the IDs of the notes the user follows and then from each ID I get the note information with another query. 
override func viewDidLoad() {
    super.viewDidLoad()

    listOfNotes.removeAll()

    //QUERY NOTES IDs IN USER

    let userRef = ref.childByAppendingPath("users/" + sessionUserID + "/participating")

    userRef.queryOrderedByValue().observeEventType(.ChildAdded, withBlock: { snapshot in

        //Saving note ID
        let savingNoteID = snapshot.key

        let notesDetailsRef = ref.childByAppendingPath("notes/" + savingNoteID + "/details")

        self.dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"

        notesDetailsRef.observeEventType(.Value, withBlock: { snapshot2 in

            let fireNoteTitle = snapshot2.value.objectForKey("noteTitle")! as! String
            let fireNoteText = snapshot2.value.objectForKey("noteText")! as! String
            let fireNoteUpdatedToConvert = snapshot2.value.objectForKey("noteUpdate")! as! String
            let fireNoteUpdatedConverted = self.dateFormatter.dateFromString(fireNoteUpdatedToConvert)

            let newNote = NoteInfo(noteID: savingNoteID as String, noteTitle: fireNoteTitle , noteUsers: "Users" as String, noteText: fireNoteText as String, noteUpdated: fireNoteUpdatedConverted!)

            listOfNotes.append(newNote)
            self.tableNotes.reloadData()

        })
    })
}

Then, selecting a row I segue to a new VC to see the info from the note.
Later, when I'm leaving the note view to go back to the list, in the viewWillDisappear, I update the noteinfo:
ref.updateChildValues([
        "notes/" + sessionNoteID + "/details/noteText": texto,
        "notes/" + sessionNoteID + "/details/noteTitle": title,
        "notes/" + sessionNoteID + "/details/noteCreator" : fireNoteCreator,
        "notes/" + sessionNoteID + "/details/noteCreation" : fireNoteCreation,
        "notes/" + sessionNoteID + "/details/noteUpdate" : String(NSDate())])

and the previously selected note appears duplicated:
(Do you know why is this happening? If I remove the update or if I just load the NoteID instead of the details it works perfectly.)
Thanks!

A:

That's doesn't appear to be duplicated, it appears another note was added to the array; the timestamp is different.
When you added an observer to the node (.Value), it is triggered once with the initial data and again every time the data changes.
In this case, if you update the data, the block will be called and a 'new' note will be added with the new time stamp.

