From 9781877db822e7cfc52d0cdbd6a4ded7b54ac571 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Thu, 23 Aug 2018 23:49:25 -0700 Subject: [PATCH] fix 1 of @mmalmi 's found bug. --- test/tmp/li.html => examples/simple/show.html | 0 {test/tmp => examples/simple}/space.html | 0 {test/tmp => examples/simple}/tables.html | 0 {test/tmp => examples/simple}/user.html | 0 gun.js | 14 +++-------- package.json | 2 +- sea.js | 5 ++-- test/common.js | 24 +++++++++++++++++++ 8 files changed, 30 insertions(+), 15 deletions(-) rename test/tmp/li.html => examples/simple/show.html (100%) rename {test/tmp => examples/simple}/space.html (100%) rename {test/tmp => examples/simple}/tables.html (100%) rename {test/tmp => examples/simple}/user.html (100%) diff --git a/test/tmp/li.html b/examples/simple/show.html similarity index 100% rename from test/tmp/li.html rename to examples/simple/show.html diff --git a/test/tmp/space.html b/examples/simple/space.html similarity index 100% rename from test/tmp/space.html rename to examples/simple/space.html diff --git a/test/tmp/tables.html b/examples/simple/tables.html similarity index 100% rename from test/tmp/tables.html rename to examples/simple/tables.html diff --git a/test/tmp/user.html b/examples/simple/user.html similarity index 100% rename from test/tmp/user.html rename to examples/simple/user.html diff --git a/gun.js b/gun.js index d467fdfb..f395a6d0 100644 --- a/gun.js +++ b/gun.js @@ -967,7 +967,6 @@ at.on('in', at); return; }*/ - //console.log("out!", at.get, get); if(get['#'] || at.soul){ get['#'] = get['#'] || at.soul; msg['#'] || (msg['#'] = text_rand(9)); @@ -1107,13 +1106,12 @@ not(at, msg); } tmp = from.id? ((at.map || (at.map = {}))[from.id] = at.map[from.id] || {at: from}) : {}; - //console.log("REL?", at.id, at.get, rel === tmp.link, tmp.pass || at.pass); if(rel === tmp.link){ if(!(tmp.pass || at.pass)){ return; } } - if(at.pass){ + if(at.pass){ Gun.obj.map(at.map, function(tmp){ tmp.pass = true }) obj_del(at, 'pass'); } @@ -1730,10 +1728,8 @@ gun.map().on(function(data, key, at, ev){ var next = (cb||noop).call(this, data, key, at, ev); if(u === next){ return } - if(data === next || Gun.is(next)){ - chain._.on('in', next._); - return; - } + if(data === next){ return chain._.on('in', at) } + if(Gun.is(next)){ return chain._.on('in', next._) } chain._.on('in', {get: key, put: next}); }); return chain; @@ -2024,11 +2020,7 @@ var wire = peer.wire; try{ if(wire.send){ - if(wire.readyState === wire.OPEN){ wire.send(raw); - } else { - (peer.queue = peer.queue || []).push(raw); - } } else if(peer.say){ peer.say(raw); diff --git a/package.json b/package.json index f121ee42..30df1026 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gun", - "version": "0.9.9998", + "version": "0.9.9999", "description": "A realtime, decentralized, offline-first, graph data synchronization engine.", "main": "index.js", "browser": "gun.min.js", diff --git a/sea.js b/sea.js index 79e3dced..fc83ff5c 100644 --- a/sea.js +++ b/sea.js @@ -1067,9 +1067,8 @@ var Gun = SEA.Gun; var then = USE('./then'); - function User(){ - this._ = {$: this} - Gun.call() + function User(root){ + this._ = {$: this}; } User.prototype = (function(){ function F(){}; F.prototype = Gun.chain; return new F() }()) // Object.create polyfill User.prototype.constructor = User; diff --git a/test/common.js b/test/common.js index 49a3a491..d933b469 100644 --- a/test/common.js +++ b/test/common.js @@ -3366,6 +3366,30 @@ describe('Gun', function(){ list.set({name: 'dave', age: 25}); }); + it('once map function once', function(done){ + var gun = Gun(), s = 'o/mf/o', u; + var app = gun.get(s); + var list = app.get('list'); + + var check = {}; + gun.get('user').get('alice').put({name:'Alice', email:'alice@example.com'}) + gun.get('user').get('bob').put({name:'Bob', email:'bob@example.com'}) + gun.get('user').get('carl').put({name:'Carl', email:'carl@example.com'}) + + gun.get('user').once().map(v => { + //console.log('this gets called', v); + return v + }).once((v, k) => { + //console.log('this is never called', k, v); + check[k] = (check[k] || 0) + 1; + if(1 === check.alice && 1 === check.bob && 1 === check.carl){ + if(done.c){return}done.c=1; + done(); + } + }); + + }); + it('val and then map', function(done){ var gun = Gun(), s = 'val/then/map', u; var list = gun.get(s);