git ssb

10+

Matt McKegg / patchwork



Commit a96cee615d9cb3fd5cf0886660391ab4ee1088c2

show icon next to people you follow on their post heading, and you!

Matt McKegg committed on 12/15/2017, 6:00:06 AM
Parent: 7cda75eab5c68ce985a6dd1154a45acc301b29ec

Files changed

plugs/message/html/layout/default.jschanged
plugs/message/html/layout/mini.jschanged
styles/dark/message.mcsschanged
styles/dark/$following.mcssadded
styles/light/message.mcsschanged
styles/light/$following.mcssadded
plugs/message/html/layout/default.jsView
@@ -7,8 +7,10 @@
77 'profile.html.person': 'first',
88 'message.obs.backlinks': 'first',
99 'message.obs.name': 'first',
1010 'message.obs.author': 'first',
11 + 'contact.obs.following': 'first',
12 + 'keys.sync.id': 'first',
1113 'message.html': {
1214 link: 'first',
1315 meta: 'map',
1416 action: 'map',
@@ -22,8 +24,16 @@
2224 exports.gives = nest('message.html.layout')
2325
2426 exports.create = function (api) {
2527 const i18n = api.intl.sync.i18n
28 + var yourFollows = null
29 +
30 + // to get sync follows
31 + setImmediate(() => {
32 + var yourId = api.keys.sync.id()
33 + yourFollows = api.contact.obs.following(yourId)
34 + })
35 +
2636 return nest('message.html.layout', layout)
2737
2838 function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true, compact = false}) {
2939 if (!(layout === undefined || layout === 'default')) return
@@ -48,8 +58,12 @@
4858 } else if (msg.value.content.project) {
4959 replyInfo = h('span', [i18n('on '), api.message.html.link(msg.value.content.project)])
5060 }
5161
62 + if (yourFollows && yourFollows().includes(msg.value.author)) {
63 + classList.push('-following')
64 + }
65 +
5266 if (compact) {
5367 classList.push('-compact')
5468 }
5569
@@ -91,22 +105,25 @@
91105
92106 // scoped
93107
94108 function messageHeader (msg, {replyInfo, priority}) {
109 + var yourId = api.keys.sync.id()
95110 var additionalMeta = []
96111 if (priority === 2) {
97112 additionalMeta.push(h('span.flag -new', {title: i18n('New Message')}))
98113 } else if (priority === 1) {
99114 additionalMeta.push(h('span.flag -unread', {title: i18n('Unread Message')}))
100115 }
116 +
101117 return h('header', [
102118 h('div.main', [
103119 h('a.avatar', {href: `${msg.value.author}`}, [
104120 api.about.html.image(msg.value.author)
105121 ]),
106122 h('div.main', [
107123 h('div.name', [
108- api.profile.html.person(msg.value.author)
124 + api.profile.html.person(msg.value.author),
125 + msg.value.author === yourId ? [' ', h('span.you', {}, i18n('(you)'))] : null
109126 ]),
110127 h('div.meta', [
111128 api.message.html.timestamp(msg), ' ',
112129 replyInfo
plugs/message/html/layout/mini.jsView
@@ -5,27 +5,44 @@
55 exports.needs = nest({
66 'profile.html.person': 'first',
77 'message.obs.backlinks': 'first',
88 'message.obs.name': 'first',
9 + 'contact.obs.following': 'first',
10 + 'keys.sync.id': 'first',
911 'message.html': {
1012 link: 'first',
1113 meta: 'map',
1214 action: 'map',
1315 timestamp: 'first',
1416 backlinks: 'first'
1517 },
16- 'about.html.image': 'first'
18 + 'about.html.image': 'first',
19 + 'intl.sync.i18n': 'first'
1720 })
1821
1922 exports.gives = nest('message.html.layout')
2023
2124 exports.create = function (api) {
25 + const i18n = api.intl.sync.i18n
26 + var yourFollows = null
27 +
28 + // to get sync follows
29 + setImmediate(() => {
30 + var yourId = api.keys.sync.id()
31 + yourFollows = api.contact.obs.following(yourId)
32 + })
33 +
2234 return nest('message.html.layout', layout)
2335
2436 function layout (msg, {layout, previousId, priority, miniContent, content, includeReferences, includeForks = true}) {
2537 if (!(layout === 'mini')) return
2638
2739 var classList = ['Message -mini']
40 +
41 + if (yourFollows && yourFollows().includes(msg.value.author)) {
42 + classList.push('-following')
43 + }
44 +
2845 var replyInfo = null
2946
3047 if (msg.value.content.root) {
3148 classList.push('-reply')
@@ -64,8 +81,9 @@
6481
6582 // scoped
6683
6784 function messageHeader (msg, {replyInfo, priority, miniContent}) {
85 + var yourId = api.keys.sync.id()
6886 var additionalMeta = []
6987 if (priority >= 2) {
7088 additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
7189 }
@@ -75,9 +93,10 @@
7593 api.about.html.image(msg.value.author)
7694 ]),
7795 h('div.main', [
7896 h('div.name', [
79- api.profile.html.person(msg.value.author)
97 + api.profile.html.person(msg.value.author),
98 + msg.value.author === yourId ? [' ', h('span.you', {}, i18n('(you)'))] : null
8099 ]),
81100 h('div.meta', [
82101 miniContent, ' ',
83102 replyInfo
styles/dark/message.mcssView
@@ -14,8 +14,20 @@
1414 :focus {
1515 z-index: 1
1616 }
1717
18 + -following {
19 + header {
20 + div.main {
21 + div.main {
22 + div.name {
23 + $following
24 + }
25 + }
26 + }
27 + }
28 + }
29 +
1830 -data {
1931 header {
2032 div.main {
2133 font-size: 80%
styles/dark/$following.mcssView
@@ -1,0 +1,16 @@
1 +$following {
2 + :after {
3 + display: inline-block
4 + content: ' '
5 + width: 20px
6 + height: 12px
7 + margin-left: 5px
8 + background: svg(subscribed) no-repeat center
9 +
10 + @svg subscribed {
11 + width: 20px
12 + height: 12px
13 + content: "<circle cx='6' stroke='#777' fill='none' cy='6' r='5' /> <circle cx='6' cy='6' r='3' fill='#777'/>"
14 + }
15 + }
16 +}
styles/light/message.mcssView
@@ -14,8 +14,20 @@
1414 :focus {
1515 z-index: 1
1616 }
1717
18 + -following {
19 + header {
20 + div.main {
21 + div.main {
22 + div.name {
23 + $following
24 + }
25 + }
26 + }
27 + }
28 + }
29 +
1830 -data {
1931 header {
2032 div.main {
2133 font-size: 80%
styles/light/$following.mcssView
@@ -1,0 +1,16 @@
1 +$following {
2 + :after {
3 + display: inline-block
4 + content: ' '
5 + width: 20px
6 + height: 12px
7 + margin-left: 3px
8 + background: svg(subscribed) no-repeat center
9 +
10 + @svg subscribed {
11 + width: 20px
12 + height: 12px
13 + content: "<circle cx='6' stroke='#BBB' fill='none' cy='6' r='5' /> <circle cx='6' cy='6' r='3' fill='#BBB'/>"
14 + }
15 + }
16 +}

Built with git-ssb-web