Skip to content

Commit 2a3b032

Browse files
committed
firebase update merge
1 parent 699e7b5 commit 2a3b032

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

my-mind.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,19 @@ MM.Item.prototype.mergeWith = function(data) {
431431
/* FIXME children - co kdyz je nekdo z nas zrovna aktivni, nerkuli editovatelny? */
432432
(data.children || []).forEach(function(child, index) {
433433
if (index >= this._children.length) { /* new child */
434+
console.log("adding new child", child, "at", index);
434435
this.insertChild(MM.Item.fromJSON(child));
435-
dirty = true;
436+
// dirty = true; FIXME to zaridi to dite, ze?
436437
} else { /* existing child */
437438
var myChild = this._children[index];
438439
if (myChild.getId() == child.id) { /* recursive merge */
440+
console.log("merging child", myChild, "with", child);
439441
myChild.mergeWith(child);
440442
} else { /* changed; replace */
441-
this._children[index] = MM.Item.fromJSON(child);
442-
dirty = true;
443+
console.log("replacing dead child", myChild, "with new", child);
444+
this.removeChild(this._children[index]);
445+
this.insertChild(MM.Item.fromJSON(child), index);
446+
// dirty = true; FIXME to zaridi to dite, ze?
443447
}
444448
}
445449
}, this);
@@ -4346,7 +4350,7 @@ MM.UI.Backend.Firebase.load = function() {
43464350

43474351
MM.UI.Backend.Firebase._load = function(id) {
43484352
MM.App.setThrobber(true);
4349-
4353+
/* FIXME posere se kdyz zmenim jeden firebase na jiny */
43504354
this._backend.load(id).then(
43514355
this._loadDone.bind(this),
43524356
this._error.bind(this)

src/item.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,19 @@ MM.Item.prototype.mergeWith = function(data) {
142142
/* FIXME children - co kdyz je nekdo z nas zrovna aktivni, nerkuli editovatelny? */
143143
(data.children || []).forEach(function(child, index) {
144144
if (index >= this._children.length) { /* new child */
145+
console.log("adding new child", child, "at", index);
145146
this.insertChild(MM.Item.fromJSON(child));
146-
dirty = true;
147+
// dirty = true; FIXME to zaridi to dite, ze?
147148
} else { /* existing child */
148149
var myChild = this._children[index];
149150
if (myChild.getId() == child.id) { /* recursive merge */
151+
console.log("merging child", myChild, "with", child);
150152
myChild.mergeWith(child);
151153
} else { /* changed; replace */
152-
this._children[index] = MM.Item.fromJSON(child);
153-
dirty = true;
154+
console.log("replacing dead child", myChild, "with new", child);
155+
this.removeChild(this._children[index]);
156+
this.insertChild(MM.Item.fromJSON(child), index);
157+
// dirty = true; FIXME to zaridi to dite, ze?
154158
}
155159
}
156160
}, this);

src/ui.backend.firebase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ MM.UI.Backend.Firebase.load = function() {
124124

125125
MM.UI.Backend.Firebase._load = function(id) {
126126
MM.App.setThrobber(true);
127-
127+
/* FIXME posere se kdyz zmenim jeden firebase na jiny */
128128
this._backend.load(id).then(
129129
this._loadDone.bind(this),
130130
this._error.bind(this)

0 commit comments

Comments
 (0)