git ssb

7+

dinoworm 🐛 / patchcore



Commit 45ca9c19d8bf4ca58b166e0097d56a1d840cef49

add sync back to about.obs.*

Matt McKegg committed on 6/27/2017, 6:08:59 AM
Parent: 72b57dbd890f33a17693afa0ca4357d5185af592

Files changed

about/obs.jschanged
about/obs.jsView
@@ -27,9 +27,10 @@
2727 ]
2828 })
2929
3030 exports.create = function (api) {
31- var sync = Value(false)
31 + var syncValue = Value(false)
32 + var sync = computed(syncValue, x => x)
3233 var cache = null
3334
3435 return nest({
3536 'about.obs': {
@@ -51,30 +52,34 @@
5152 groupedValues
5253 }
5354 })
5455
55-
5656 function valueFrom (id, key, author) {
5757 if (!ref.isLink(id)) throw new Error('About requires an ssb ref!')
58- return computed([get(id), key, author], getValueFrom)
58 + return withSync(computed([get(id), key, author], getValueFrom))
5959 }
6060
6161 function latestValue (id, key) {
6262 if (!ref.isLink(id)) throw new Error('About requires an ssb ref!')
63- return computed([get(id), key], getLatestValue)
63 + return withSync(computed([get(id), key], getLatestValue))
6464 }
6565
6666 function socialValue (id, key, defaultValue) {
6767 if (!ref.isLink(id)) throw new Error('About requires an ssb ref!')
6868 var yourId = api.keys.sync.id()
69- return computed([get(id), key, id, yourId, defaultValue], getSocialValue)
69 + return withSync(computed([get(id), key, id, yourId, defaultValue], getSocialValue))
7070 }
7171
7272 function groupedValues (id, key) {
7373 if (!ref.isLink(id)) throw new Error('About requires an ssb ref!')
74- return computed([get(id), key], getGroupedValues)
74 + return withSync(computed([get(id), key], getGroupedValues))
7575 }
7676
77 + function withSync (obs) {
78 + obs.sync = sync
79 + return obs
80 + }
81 +
7782 function get (id) {
7883 if (!ref.isLink(id)) throw new Error('About requires an ssb ref!')
7984 load()
8085 if (!cache[id]) {
@@ -108,10 +113,10 @@
108113 state.set(lastState)
109114 }
110115 }
111116
112- if (!sync()) {
113- sync.set(true)
117 + if (!syncValue()) {
118 + syncValue.set(true)
114119 }
115120 })
116121 )
117122 }

Built with git-ssb-web