git ssb

10+

Matt McKegg / patchwork



Commit e79d34134f281a91928cfc9729fcc40cdc3a88d4

standardize!

Matt McKegg committed on 10/19/2017, 2:53:42 AM
Parent: a69b107634854812d8fe243ff4f0ce3e4e19bd8c

Files changed

plugs/message/html/meta/likes.jschanged
plugs/message/html/render/about.jschanged
plugs/message/html/render/attending.jschanged
plugs/message/html/render/channel.jschanged
plugs/message/html/render/following.jschanged
plugs/message/html/render/gathering.jschanged
plugs/message/html/meta/likes.jsView
@@ -5,9 +5,9 @@
55 exports.needs = nest({
66 'message.obs.likes': 'first',
77 'sheet.profiles': 'first',
88 'about.obs.name': 'first',
9- 'intl.sync.i18n': 'first',
9+ 'intl.sync.i18n': 'first'
1010 })
1111
1212 exports.create = function (api) {
1313 const i18n = api.intl.sync.i18n
plugs/message/html/render/about.jsView
@@ -13,9 +13,9 @@
1313 'keys.sync.id': 'first',
1414 'profile.html.person': 'first',
1515 'about.obs.name': 'first',
1616 'blob.sync.url': 'first',
17- 'intl.sync.i18n': 'first',
17+ 'intl.sync.i18n': 'first'
1818 })
1919
2020 exports.gives = nest('message.html', {
2121 canRender: true,
@@ -26,9 +26,9 @@
2626 const i18n = api.intl.sync.i18n
2727 return nest('message.html', {
2828 canRender: isRenderable,
2929 render: function (msg, opts) {
30- if (!isRenderable(msg)) return;
30+ if (!isRenderable(msg)) return
3131
3232 var c = msg.value.content
3333 var self = msg.value.author === c.about
3434
@@ -85,10 +85,10 @@
8585 return elements
8686 }
8787 })
8888
89- function isRenderable(msg) {
90- if (msg.value.content.type !== 'about') return undefined
91- else if (!ref.isFeed(msg.value.content.about)) return undefined
89+ function isRenderable (msg) {
90+ if (msg.value.content.type !== 'about') return
91+ if (!ref.isFeed(msg.value.content.about)) return
9292 return true
9393 }
9494 }
plugs/message/html/render/attending.jsView
@@ -15,12 +15,12 @@
1515 canRender: true,
1616 render: true
1717 })
1818
19-exports.create = function(api) {
19+exports.create = function (api) {
2020 return nest('message.html', {
2121 canRender: isRenderable,
22- render: function about(msg, opts) {
22+ render: function about (msg, opts) {
2323 if (!isRenderable(msg)) return
2424
2525 var action = msg.value.content.attendee.remove ? `can't attend` : 'is attending'
2626 var target = msg.value.content.about
@@ -38,12 +38,12 @@
3838 })
3939 }
4040 })
4141
42- function isRenderable(msg) {
43- if (msg.value.content.type !== 'about') return undefined
44- else if (!ref.isMsg(msg.value.content.about)) return undefined
45- else if (!msg.value.content.attendee) return undefined
46- else if (msg.value.content.attendee.link !== msg.value.author) return undefined
47- else return true
42+ function isRenderable (msg) {
43+ if (msg.value.content.type !== 'about') return
44+ if (!ref.isMsg(msg.value.content.about)) return
45+ if (!msg.value.content.attendee) return
46+ if (msg.value.content.attendee.link !== msg.value.author) return
47+ return true
4848 }
4949 }
plugs/message/html/render/channel.jsView
@@ -6,17 +6,17 @@
66 'message.html': {
77 decorate: 'reduce',
88 layout: 'first'
99 },
10- 'intl.sync.i18n': 'first',
10+ 'intl.sync.i18n': 'first'
1111 })
1212
1313 exports.gives = nest('message.html', {
1414 canRender: true,
1515 render: true
1616 })
1717
18-exports.create = function(api) {
18+exports.create = function (api) {
1919 const i18n = api.intl.sync.i18n
2020 return nest('message.html', {
2121 canRender: isRenderable,
2222 render: function (msg, opts) {
@@ -31,9 +31,9 @@
3131 })
3232 }
3333 })
3434
35- function messageContent(msg) {
35+ function messageContent (msg) {
3636 var channel = `#${msg.value.content.channel}`
3737 var subscribed = msg.value.content.subscribed
3838 return [
3939 subscribed ? i18n('subscribed to ') : i18n('unsubscribed from '),
@@ -43,7 +43,7 @@
4343 ]
4444 }
4545 }
4646
47-function isRenderable(msg) {
47+function isRenderable (msg) {
4848 return msg.value.content.type === 'channel' ? true : undefined
4949 }
plugs/message/html/render/following.jsView
@@ -1,5 +1,4 @@
1-var h = require('mutant/h')
21 var nest = require('depnest')
32 var extend = require('xtend')
43 var ref = require('ssb-ref')
54
@@ -8,21 +7,21 @@
87 decorate: 'reduce',
98 layout: 'first'
109 },
1110 'profile.html.person': 'first',
12- 'intl.sync.i18n': 'first',
11+ 'intl.sync.i18n': 'first'
1312 })
1413
1514 exports.gives = nest('message.html', {
1615 canRender: true,
1716 render: true
1817 })
1918
20-exports.create = function(api) {
19+exports.create = function (api) {
2120 const i18n = api.intl.sync.i18n
2221 return nest('message.html', {
2322 canRender: isRenderable,
24- render: function(msg, opts) {
23+ render: function (msg, opts) {
2524 if (!isRenderable(msg)) return
2625
2726 var element = api.message.html.layout(msg, extend({
2827 miniContent: messageContent(msg),
@@ -34,9 +33,9 @@
3433 })
3534 }
3635 })
3736
38- function messageContent(msg) {
37+ function messageContent (msg) {
3938 var following = msg.value.content.following
4039 var blocking = msg.value.content.blocking
4140
4241 if (blocking === true) {
@@ -54,12 +53,11 @@
5453 ]
5554 }
5655 }
5756
58- function isRenderable(msg) {
59- if (msg.value.content.type !== 'contact') return undefined
60- else if (!ref.isFeed(msg.value.content.contact)) return undefined
61- else if (typeof msg.value.content.following !== 'boolean' && typeof msg.value.content.blocking !== 'boolean') return undefined
62- return true;
57+ function isRenderable (msg) {
58+ if (msg.value.content.type !== 'contact') return
59+ if (!ref.isFeed(msg.value.content.contact)) return
60+ if (typeof msg.value.content.following !== 'boolean' && typeof msg.value.content.blocking !== 'boolean') return
61+ return true
6362 }
64-
6563 }
plugs/message/html/render/gathering.jsView
@@ -23,14 +23,14 @@
2323 canRender: true,
2424 render: true
2525 })
2626
27-exports.create = function(api) {
27+exports.create = function (api) {
2828 var following = null
2929
3030 return nest('message.html', {
3131 canRender: isRenderable,
32- render: function(msg, opts) {
32+ render: function (msg, opts) {
3333 if (!isRenderable(msg)) return
3434
3535 var yourId = api.keys.sync.id()
3636 var hidden = api.about.obs.valueFrom(msg.key, 'hidden', yourId)
@@ -38,9 +38,9 @@
3838 var title = api.about.obs.latestValue(msg.key, 'title')
3939 var description = api.about.obs.latestValue(msg.key, 'description')
4040 var location = api.about.obs.latestValue(msg.key, 'location')
4141 var startDateTime = api.about.obs.latestValue(msg.key, 'startDateTime')
42- var endDateTime = api.about.obs.latestValue(msg.key, 'endDateTime')
42+ // var endDateTime = api.about.obs.latestValue(msg.key, 'endDateTime')
4343 var attendees = computed([api.about.obs.groupedValues(msg.key, 'attendee')], getAttendees)
4444 if (!following) {
4545 following = api.contact.obs.following(yourId)
4646 }
@@ -102,9 +102,9 @@
102102 }))
103103 }
104104 })
105105
106- function publishAttending(id) {
106+ function publishAttending (id) {
107107 var yourId = api.keys.sync.id()
108108
109109 // publish with confirm
110110 api.message.async.publish({
@@ -115,9 +115,9 @@
115115 }
116116 })
117117 }
118118
119- function publishNotAttending(id) {
119+ function publishNotAttending (id) {
120120 var yourId = api.keys.sync.id()
121121
122122 // publish with confirm
123123 api.message.async.publish({
@@ -129,11 +129,11 @@
129129 }
130130 })
131131 }
132132
133- function nameAndFollowWarning(id) {
133+ function nameAndFollowWarning (id) {
134134 var yourId = api.keys.sync.id()
135- return computed([api.about.obs.name(id), id, following], function nameAndFollowWarning(name, id, following) {
135+ return computed([api.about.obs.name(id), id, following], function nameAndFollowWarning (name, id, following) {
136136 if (id === yourId) {
137137 return `${name} (you)`
138138 } else if (following.includes(id)) {
139139 return `${name}`
@@ -142,24 +142,24 @@
142142 }
143143 })
144144 }
145145
146- function markdown(obs) {
146+ function markdown (obs) {
147147 return computed(obs, (text) => {
148148 if (typeof text === 'string') return api.message.html.markdown(text)
149149 })
150150 }
151151 }
152152
153-function formatTime(time) {
153+function formatTime (time) {
154154 if (time && time.epoch) {
155155 return moment(time.epoch).format('LLLL')
156156 }
157157 }
158158
159-function getAttendees(lookup) {
159+function getAttendees (lookup) {
160160 return Object.keys(lookup)
161161 }
162162
163-function isRenderable(msg) {
163+function isRenderable (msg) {
164164 return (msg.value.content.type === 'gathering') ? true : undefined
165165 }

Built with git-ssb-web