Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
helperjs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Team
helperjs
Commits
3393586b
There was a problem fetching the pipeline summary.
Commit
3393586b
authored
8 years ago
by
clemo
Browse files
Options
Downloads
Patches
Plain Diff
format changes
Signed-off-by:
clemo
<
clemo@cbcode.at
>
parent
22d0d537
Branches
master
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/ssb-cache/index.js
+20
-13
20 additions, 13 deletions
lib/ssb-cache/index.js
with
20 additions
and
13 deletions
lib/ssb-cache/index.js
+
20
−
13
View file @
3393586b
...
...
@@ -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
(
u
ser
,
value
,
next
){
this
.
getUserById
(
value
.
author
,(
err
,
author
)
=>
{
updateUserContact
(
contactU
ser
,
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
);
}
u
ser
.
follower
[
value
.
author
]
=
1
;
this
.
cacheDB
.
put
(
user
.
key
,
user
,
next
);
contactU
ser
.
follower
[
value
.
author
]
=
1
;
this
.
cacheDB
.
put
(
contactUser
.
key
,
contactUser
,
next
);
//save follower
});
});
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment