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 AMParent: 7cda75eab5c68ce985a6dd1154a45acc301b29ec
Files changed
plugs/message/html/layout/default.js | ||
---|---|---|
@@ -7,8 +7,10 @@ | ||
7 | 7 | 'profile.html.person': 'first', |
8 | 8 | 'message.obs.backlinks': 'first', |
9 | 9 | 'message.obs.name': 'first', |
10 | 10 | 'message.obs.author': 'first', |
11 | + 'contact.obs.following': 'first', | |
12 | + 'keys.sync.id': 'first', | |
11 | 13 | 'message.html': { |
12 | 14 | link: 'first', |
13 | 15 | meta: 'map', |
14 | 16 | action: 'map', |
@@ -22,8 +24,16 @@ | ||
22 | 24 | exports.gives = nest('message.html.layout') |
23 | 25 | |
24 | 26 | exports.create = function (api) { |
25 | 27 | 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 | + | |
26 | 36 | return nest('message.html.layout', layout) |
27 | 37 | |
28 | 38 | function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true, compact = false}) { |
29 | 39 | if (!(layout === undefined || layout === 'default')) return |
@@ -48,8 +58,12 @@ | ||
48 | 58 | } else if (msg.value.content.project) { |
49 | 59 | replyInfo = h('span', [i18n('on '), api.message.html.link(msg.value.content.project)]) |
50 | 60 | } |
51 | 61 | |
62 | + if (yourFollows && yourFollows().includes(msg.value.author)) { | |
63 | + classList.push('-following') | |
64 | + } | |
65 | + | |
52 | 66 | if (compact) { |
53 | 67 | classList.push('-compact') |
54 | 68 | } |
55 | 69 | |
@@ -91,22 +105,25 @@ | ||
91 | 105 | |
92 | 106 | // scoped |
93 | 107 | |
94 | 108 | function messageHeader (msg, {replyInfo, priority}) { |
109 | + var yourId = api.keys.sync.id() | |
95 | 110 | var additionalMeta = [] |
96 | 111 | if (priority === 2) { |
97 | 112 | additionalMeta.push(h('span.flag -new', {title: i18n('New Message')})) |
98 | 113 | } else if (priority === 1) { |
99 | 114 | additionalMeta.push(h('span.flag -unread', {title: i18n('Unread Message')})) |
100 | 115 | } |
116 | + | |
101 | 117 | return h('header', [ |
102 | 118 | h('div.main', [ |
103 | 119 | h('a.avatar', {href: `${msg.value.author}`}, [ |
104 | 120 | api.about.html.image(msg.value.author) |
105 | 121 | ]), |
106 | 122 | h('div.main', [ |
107 | 123 | 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 | |
109 | 126 | ]), |
110 | 127 | h('div.meta', [ |
111 | 128 | api.message.html.timestamp(msg), ' ', |
112 | 129 | replyInfo |
plugs/message/html/layout/mini.js | ||
---|---|---|
@@ -5,27 +5,44 @@ | ||
5 | 5 | exports.needs = nest({ |
6 | 6 | 'profile.html.person': 'first', |
7 | 7 | 'message.obs.backlinks': 'first', |
8 | 8 | 'message.obs.name': 'first', |
9 | + 'contact.obs.following': 'first', | |
10 | + 'keys.sync.id': 'first', | |
9 | 11 | 'message.html': { |
10 | 12 | link: 'first', |
11 | 13 | meta: 'map', |
12 | 14 | action: 'map', |
13 | 15 | timestamp: 'first', |
14 | 16 | backlinks: 'first' |
15 | 17 | }, |
16 | - 'about.html.image': 'first' | |
18 | + 'about.html.image': 'first', | |
19 | + 'intl.sync.i18n': 'first' | |
17 | 20 | }) |
18 | 21 | |
19 | 22 | exports.gives = nest('message.html.layout') |
20 | 23 | |
21 | 24 | 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 | + | |
22 | 34 | return nest('message.html.layout', layout) |
23 | 35 | |
24 | 36 | function layout (msg, {layout, previousId, priority, miniContent, content, includeReferences, includeForks = true}) { |
25 | 37 | if (!(layout === 'mini')) return |
26 | 38 | |
27 | 39 | var classList = ['Message -mini'] |
40 | + | |
41 | + if (yourFollows && yourFollows().includes(msg.value.author)) { | |
42 | + classList.push('-following') | |
43 | + } | |
44 | + | |
28 | 45 | var replyInfo = null |
29 | 46 | |
30 | 47 | if (msg.value.content.root) { |
31 | 48 | classList.push('-reply') |
@@ -64,8 +81,9 @@ | ||
64 | 81 | |
65 | 82 | // scoped |
66 | 83 | |
67 | 84 | function messageHeader (msg, {replyInfo, priority, miniContent}) { |
85 | + var yourId = api.keys.sync.id() | |
68 | 86 | var additionalMeta = [] |
69 | 87 | if (priority >= 2) { |
70 | 88 | additionalMeta.push(h('span.flag -new', {title: 'New Message'})) |
71 | 89 | } |
@@ -75,9 +93,10 @@ | ||
75 | 93 | api.about.html.image(msg.value.author) |
76 | 94 | ]), |
77 | 95 | h('div.main', [ |
78 | 96 | 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 | |
80 | 99 | ]), |
81 | 100 | h('div.meta', [ |
82 | 101 | miniContent, ' ', |
83 | 102 | replyInfo |
styles/dark/message.mcss | ||
---|---|---|
@@ -14,8 +14,20 @@ | ||
14 | 14 | :focus { |
15 | 15 | z-index: 1 |
16 | 16 | } |
17 | 17 | |
18 | + -following { | |
19 | + header { | |
20 | + div.main { | |
21 | + div.main { | |
22 | + div.name { | |
23 | + $following | |
24 | + } | |
25 | + } | |
26 | + } | |
27 | + } | |
28 | + } | |
29 | + | |
18 | 30 | -data { |
19 | 31 | header { |
20 | 32 | div.main { |
21 | 33 | font-size: 80% |
styles/dark/$following.mcss | ||
---|---|---|
@@ -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.mcss | ||
---|---|---|
@@ -14,8 +14,20 @@ | ||
14 | 14 | :focus { |
15 | 15 | z-index: 1 |
16 | 16 | } |
17 | 17 | |
18 | + -following { | |
19 | + header { | |
20 | + div.main { | |
21 | + div.main { | |
22 | + div.name { | |
23 | + $following | |
24 | + } | |
25 | + } | |
26 | + } | |
27 | + } | |
28 | + } | |
29 | + | |
18 | 30 | -data { |
19 | 31 | header { |
20 | 32 | div.main { |
21 | 33 | font-size: 80% |
styles/light/$following.mcss | ||
---|---|---|
@@ -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