val stream flag driver fix, chat app use val

This commit is contained in:
Mark Nadal 2015-06-17 18:10:06 -07:00
parent bd2c5134c4
commit b3fbf01153
2 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../../gun.js"></script>
</head>
<body>
<style>
html, body { font-size: 14pt; }
@ -19,12 +23,11 @@
<input class="what" placeholder="message">
<button>send</button>
</form>
<script src="../../gun.js"></script>
<script>
var chat = Gun(location.origin + '/gun').get('example/chat/data').not(function(){
return this.put({1: {who: 'Welcome', what: "to the chat app!", when: 1}}).key('example/chat/data');
});
chat.map().on(function(msg, field){
chat.map().val(function(msg, field){
var $ul = $('ul'), $last = $.sort(field, $ul.lastChild), $msg;
($msg = $("#msg-" + field) || $ul.insertBefore($.model.cloneNode(true), $last.nextSibling)).id = 'msg-' + field;
$('.who', $msg)[$.text] = msg.who;

6
gun.js
View File

@ -942,6 +942,7 @@
o.url.pathname = '/' + key;
}
Gun.log("tab get --->", key);
// to comment out or not to?
(function local(key, cb){
var node, lkey = key[Gun._.soul]? tab.prefix + tab.prenode + key[Gun._.soul]
: tab.prefix + tab.prekey + key
@ -951,6 +952,7 @@
cb(null, {_: {'#': Gun.is.soul.on(node) }}); // TODO: Don't have the symbols hard coded.
},0) }
}(key, cb));
//console.log("DO NOT COMMIT WITH LOCALSTORAGE COMMENTED OUT!");
Gun.obj.map(gun.__.opt.peers, function(peer, url){
request(url, null, function(err, reply){
reply.body = reply.body || reply.chunk || reply.end || reply.write;
@ -1029,7 +1031,9 @@
Gun.obj.map(gun.__.opt.peers, function(){ // only create server if peers and do it once by returning immediately.
return tab.request = tab.request || request.createServer(function(req, res){
if(!req.body){ return }
if(Gun.is.node(req.body) || Gun.is.graph(req.body)){
if(Gun.is.node(req.body) || Gun.is.graph(req.body, function(node, soul){
gun.__.flag.end[soul] = true; // TODO! Put this in CORE not in TAB driver?
})){
Gun.log("client server received request", req);
Gun.union(gun, req.body); // TODO: BUG? Interesting, this won't update localStorage because .put isn't called?
}