Skip to content
Snippets Groups Projects
Commit 3393586b authored by clemo's avatar clemo
Browse files

format changes


Signed-off-by: default avatarclemo <clemo@cbcode.at>
parent 22d0d537
Branches master
No related tags found
No related merge requests found
Pipeline #
......@@ -100,12 +100,14 @@ export class ssbCache extends Ssb {
cb(err);
});
}
/**
* fill cache from last node like collect but live
* @param {function} cb - `(err) => {...}`
* @return {object} liveFeed - `liveFeed.stop();` //will trigger cb
**/
collectLive(cb){
// let _on = {'msg':[]}
let _stop = false;
this.syncLastNode((err)=> {
if(err){
......@@ -119,7 +121,7 @@ export class ssbCache extends Ssb {
args[1](true); //next(true) = end of stream
}else{
//trigger!
this.addMsg(...args)
this.addMsg(...args);
}
},(err,...args) => {
if(err){
......@@ -129,10 +131,15 @@ export class ssbCache extends Ssb {
}
}));
});
return {stop(){
_stop = true;
cb();
}};
return {
stop(){
_stop = true;
cb();
},
/*on(type,fn){
_on[type].push(fn);
}*/
};
}
/**add types of msgs you are interested in(t1,t2,...)
......@@ -160,7 +167,7 @@ export class ssbCache extends Ssb {
return next("id not defined");
}
if(data.timestamp < this.lastNode){
return next(`timestamp mismatch rm -r ${this.keyPath}/idea-cache`);
return next(`timestamp mismatch \`rm -r ${this.keyPath}/idea-cache\` datatime: ${data.timestamp}, lastnode: ${this.lastNode}`);
}
if('undefined' === typeof data.value.content){
dbug('addMsg content not defined',data);
......@@ -208,7 +215,6 @@ export class ssbCache extends Ssb {
**/
updateUserType(author,data,next){
const value = data.value;
// dbug('add UserType: '+value.content.type);
if('undefined' === typeof author.types[value.content.type]){
author.types[value.content.type] = {};
}
......@@ -262,18 +268,19 @@ export class ssbCache extends Ssb {
* @param {object} value - new value msg
* @param {function} next - cb
*/
updateUserContact(user,value,next){
this.getUserById(value.author,(err,author) => {
updateUserContact(contactUser,value,next){
this.getUserById(value.author,(err,author) => { //get follower
if(err){
return next(err);
}
author.following[value.content.contact] = 1;
this.cacheDB.put(author.key,author,(err) => {
// dbug('contact:',value);
author.following[contactUser.id] = value.content.following?1:0;
this.cacheDB.put(author.key,author,(err) => { //save author
if(err){
return next(err);
}
user.follower[value.author] = 1;
this.cacheDB.put(user.key,user,next);
contactUser.follower[value.author] = 1;
this.cacheDB.put(contactUser.key,contactUser,next); //save follower
});
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment