git ssb

2+

mixmix / ticktack



Commit 6712e94224526c0480342ad6ae1f205266d341a3

fix context to protect against vote messages

mix irving committed on 10/11/2017, 1:13:17 AM
Parent: ce052deca0217916e61e6c6d4ba3f7459883a09c

Files changed

app/html/context.jschanged
app/html/thread.jschanged
app/html/context.jsView
@@ -32,8 +32,9 @@
3232
3333 pull(
3434 next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
3535 pull.filter(msg => msg.value.content.recps),
36+ pull.filter(msg => msg.value.content.type === 'post'), // TODO is this the best way to protect against votes?
3637 pull.drain(msg => {
3738 msg.value.content.recps
3839 .map(recp => typeof recp === 'object' ? recp.link : recp)
3940 .filter(recp => recp != myKey)
@@ -53,30 +54,30 @@
5354 function LevelOneContext () {
5455
5556 return h('div.level.-one', [
5657 // Nearby
57- computed(nearby, n => !isEmpty(n) ? h('header', strings.peopleNearby) : null), // TODO translate
58+ computed(nearby, n => !isEmpty(n) ? h('header', strings.peopleNearby) : null),
5859 map(nearby, feedId => Option({
5960 notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, // TODO
6061 imageEl: api.about.html.image(feedId), // TODO make avatar
6162 label: api.about.obs.name(feedId),
63+ selected: location.feed === feedId,
6264 location: computed(recentPeersContacted, recent => {
6365 const lastMsg = recent[feedId]
6466 return lastMsg
6567 ? Object.assign(lastMsg, { feed: feedId })
6668 : { page: 'threadNew', feed: feedId }
6769 }),
68- selected: location.feed === feedId
6970 })),
7071 computed(nearby, n => !isEmpty(n) ? h('hr') : null),
7172
7273 // Discover
7374 Option({
7475 notifications: Math.floor(Math.random()*5+1),
7576 imageEl: h('i.fa.fa-binoculars'),
7677 label: strings.blogIndex.title,
78+ selected: ['blogIndex', 'home'].includes(location.page),
7779 location: { page: 'blogIndex' },
78- selected: ['blogIndex', 'home'].includes(location.page)
7980 }),
8081
8182 // Recent Messages
8283 map(dictToCollection(recentPeersContacted), ({ key, value }) => {
@@ -87,10 +88,10 @@
8788 return Option({
8889 notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, // TODO
8990 imageEl: api.about.html.image(feedId), // TODO make avatar
9091 label: api.about.obs.name(feedId),
91- location: Object.assign(lastMsg, { feed: feedId }),
92- selected: location.feed === feedId
92+ selected: location.feed === feedId,
93+ location: Object.assign(lastMsg, { feed: feedId }) // TODO make obs?
9394 })
9495 })
9596 ])
9697 }
@@ -120,19 +121,21 @@
120121 label: h('Button', strings.threadNew.action.new),
121122 }),
122123 map(threads, thread => {
123124 return Option({
125+ label: api.message.html.subject(thread),
124126 selected: thread.key === root,
125127 location: Object.assign(thread, { feed: targetUser }),
126- label: api.message.html.subject(thread)
127128 })
128129 })
129130 ])
130131 }
131132
132133 function Option ({ notifications = 0, imageEl, label, location, selected }) {
133134 const className = selected ? '-selected' : ''
134- const goToLocation = () => api.history.sync.push(resolve(location))
135+ const goToLocation = () => {
136+ api.history.sync.push(resolve(location))
137+ }
135138
136139 if (!imageEl) {
137140 return h('Option', { className, 'ev-click': goToLocation }, [
138141 h('div.label', label)
app/html/thread.jsView
@@ -68,10 +68,17 @@
6868 var _chunk = null
6969 var _lastMsg = null
7070
7171 msgs.forEach(msg => {
72- if (!_lastMsg || !isSameAuthor(_lastMsg, msg)) { createNewChunk(msg) } else { _chunk.push(msg) }
72+ const text = get(msg, 'value.content.text')
73+ if (!text) return
7374
75+ if (!_lastMsg || !isSameAuthor(_lastMsg, msg)) {
76+ createNewChunk(msg)
77+ } else {
78+ _chunk.push(msg)
79+ }
80+
7481 _lastMsg = msg
7582 })
7683
7784 function createNewChunk (msg) {

Built with git-ssb-web