git ssb

16+

Dominic / patchbay



Commit fa10ca34011578ba930c05f7c0cfb3fd1c465999

about refactor

mix irving committed on 4/3/2017, 6:02:19 AM
Parent: 0df4a099fb2371f61e7eeda542c84a1c9e70436e

Files changed

about/async/suggest.jschanged
about/html/edit.jschanged
about/async/suggest.jsView
@@ -16,9 +16,11 @@
1616 exports.create = function (api) {
1717 var suggestions = null
1818 var recentSuggestions = null
1919
20- return nest('about.async.suggest', function () {
20+ return nest('about.async.suggest', suggest)
21+
22+ function suggest () {
2123 loadSuggestions()
2224 return function (word) {
2325 if (!word) {
2426 return recentSuggestions()
@@ -27,34 +29,34 @@
2729 return item.title.toLowerCase().startsWith(word.toLowerCase())
2830 })
2931 }
3032 }
31- })
33+ }
3234
3335 function loadSuggestions () {
34- if (!suggestions) {
35- var id = api.keys.sync.id()
36- var following = api.contact.obs.following(id)
37- var recentlyUpdated = api.feed.obs.recent()
38- var contacts = computed([following, recentlyUpdated], function (a, b) {
39- var result = Array.from(a)
40- b.forEach((item, i) => {
41- if (!result.includes(item)) {
42- result.push(item)
43- }
44- })
45- return result
36+ if (suggestions) return
37+
38+ var id = api.keys.sync.id()
39+ var following = api.contact.obs.following(id)
40+ var recentlyUpdated = api.feed.obs.recent()
41+ var contacts = computed([following, recentlyUpdated], (a, b) => {
42+ var result = Array.from(a)
43+ b.forEach(item => {
44+ if (!result.includes(item)) {
45+ result.push(item)
46+ }
4647 })
48+ return result
49+ })
4750
48- recentSuggestions = map(
49- computed(recentlyUpdated, (items) => Array.from(items).slice(0, 10)),
50- suggestion,
51- {idle: true}
52- )
53- suggestions = map(contacts, suggestion, {idle: true})
54- watch(recentSuggestions)
55- watch(suggestions)
56- }
51+ recentSuggestions = map(
52+ computed(recentlyUpdated, (items) => Array.from(items).slice(0, 10)),
53+ suggestion,
54+ {idle: true}
55+ )
56+ suggestions = map(contacts, suggestion, {idle: true})
57+ watch(recentSuggestions)
58+ watch(suggestions)
5759 }
5860
5961 function suggestion (id) {
6062 var name = api.about.obs.name(id)
about/html/edit.jsView
@@ -135,9 +135,8 @@
135135
136136 if (data) {
137137 var _data = dataurl.parse(data)
138138
139-
140139 api.sbot.async.addBlob(pull.once(_data.data), (err, hash) => {
141140 if (err) throw err // TODO check if this is safely caught by error catcher
142141
143142 avatar.new.set({

Built with git-ssb-web