git ssb

10+

Matt McKegg / patchwork



Commit 3a294e357e15360aded899e2d83d79b4e4c584ea

add "Send Private Message" button to profile page

fixes #584
Matt McKegg committed on 9/30/2017, 6:17:26 AM
Parent: 84f42d561913f861b364caecc35050feadc23744

Files changed

locales/en.jsonchanged
modules/message/html/compose.jschanged
modules/message/sheet/likes.jschanged
modules/page/html/render/private.jschanged
modules/page/html/render/profile.jschanged
styles/dark/compose.mcsschanged
styles/dark/private-message-button.mcssadded
styles/light/compose.mcsschanged
styles/light/private-message-button.mcssadded
locales/en.jsonView
@@ -136,6 +136,9 @@
136136 "Close": "Close",
137137 "New Message": "New Message",
138138 "unsubscribed from ": "unsubscribed from ",
139139 "en": "en",
140- "on ": "on "
141-}
140+ "on ": "on ",
141+ "Private Message": "Private Message",
142+ "Send Private Message": "Send Private Message",
143+ "Publish Privately": "Publish Privately"
144+}
modules/message/html/compose.jsView
@@ -22,9 +22,9 @@
2222 exports.gives = nest('message.html.compose')
2323
2424 exports.create = function (api) {
2525 const i18n = api.intl.sync.i18n
26- return nest('message.html.compose', function ({shrink = true, meta, hooks, prepublish, placeholder = 'Write a message'}, cb) {
26+ return nest('message.html.compose', function ({shrink = true, isPrivate, meta, hooks, prepublish, placeholder = 'Write a message'}, cb) {
2727 var files = []
2828 var filesById = {}
2929 var focused = Value(false)
3030 var hasContent = Value(false)
@@ -96,10 +96,16 @@
9696 }
9797
9898 var publishBtn = h('button', {
9999 'ev-click': publish,
100+ classList: [
101+ when(isPrivate, '-private')
102+ ],
100103 disabled: publishing
101- }, when(publishing, i18n('Publishing...'), i18n('Publish')))
104+ }, when(publishing,
105+ i18n('Publishing...'),
106+ when(isPrivate, i18n('Publish Privately'), i18n('Publish'))
107+ ))
102108
103109 var actions = h('section.actions', [
104110 fileInput,
105111 publishBtn
@@ -119,8 +125,13 @@
119125 composer.focus = function () {
120126 textArea.focus()
121127 }
122128
129+ composer.setText = function (value) {
130+ textArea.value = value
131+ hasContent.set(!!textArea.value)
132+ }
133+
123134 addSuggest(textArea, (inputText, cb) => {
124135 if (inputText[0] === '@') {
125136 cb(null, getProfileSuggestions(inputText.slice(1)))
126137 } else if (inputText[0] === '#') {
modules/message/sheet/likes.jsView
@@ -9,9 +9,9 @@
99 'profile.obs.rank': 'first',
1010 'about.html.image': 'first',
1111 'about.obs.name': 'first',
1212 'app.navigate': 'first',
13- 'intl.sync.i18n': 'first',
13+ 'intl.sync.i18n': 'first'
1414 })
1515
1616 exports.gives = nest('message.sheet.likes')
1717
modules/page/html/render/private.jsView
@@ -6,30 +6,42 @@
66 'feed.pull.private': 'first',
77 'message.html.compose': 'first',
88 'keys.sync.id': 'first',
99 'intl.sync.i18n': 'first',
10+ 'about.obs.name': 'first'
1011 })
1112
1213 exports.gives = nest('page.html.render')
1314
1415 exports.create = function (api) {
15- const i18n = api.intl.sync.i18n
1616 return nest('page.html.render', function channel (path) {
1717 if (path !== '/private') return
1818
19+ const i18n = api.intl.sync.i18n
1920 var id = api.keys.sync.id()
20- var prepend = [
21- api.message.html.compose({
22- meta: {type: 'post'},
23- prepublish: function (msg) {
24- msg.recps = [id].concat(msg.mentions).filter(function (e) {
25- return ref.isFeed(typeof e === 'string' ? e : e.link)
26- })
27- return msg
28- },
29- placeholder: i18n('Write a private message')
30- })
31- ]
21+ var compose = api.message.html.compose({
22+ meta: {type: 'post'},
23+ isPrivate: true,
24+ prepublish: function (msg) {
25+ msg.recps = [id].concat(msg.mentions).filter(function (e) {
26+ return ref.isFeed(typeof e === 'string' ? e : e.link)
27+ })
28+ return msg
29+ },
30+ placeholder: i18n('Write a private message')
31+ })
3232
33- return api.feed.html.rollup(api.feed.pull.private, { prepend })
33+ var view = api.feed.html.rollup(api.feed.pull.private, { prepend: [compose] })
34+
35+ view.setAnchor = function (data) {
36+ if (data && data.compose && data.compose.to) {
37+ var name = api.about.obs.name(data.compose.to)
38+ compose.setText(`[${name()}](${data.compose.to})\n\n`, true)
39+ window.requestAnimationFrame(() => {
40+ compose.focus()
41+ })
42+ }
43+ }
44+
45+ return view
3446 })
3547 }
modules/page/html/render/profile.jsView
@@ -22,8 +22,9 @@
2222 'keys.sync.id': 'first',
2323 'sheet.display': 'first',
2424 'profile.obs.rank': 'first',
2525 'profile.sheet.edit': 'first',
26+ 'app.navigate': 'first',
2627 'contact.obs': {
2728 followers: 'first',
2829 following: 'first'
2930 },
@@ -177,8 +178,9 @@
177178 h('div.main', [
178179 feedView
179180 ]),
180181 h('div.side.-right', [
182+ h('button PrivateMessageButton', {'ev-click': () => api.app.navigate('/private', {compose: {to: id}})}, i18n('Send Private Message')),
181183 when(friendsLoaded,
182184 h('div', [
183185 renderContactBlock(i18n('Friends'), friends, yourFollows),
184186 renderContactBlock(i18n('Followers'), followers, yourFollows),
styles/dark/compose.mcssView
@@ -110,8 +110,13 @@
110110 button {
111111 :hover {
112112 background: #6f74e5
113113 }
114+ -private {
115+ :hover {
116+ background: #ceab2f
117+ }
118+ }
114119 }
115120 }
116121
117122 -expanded {
styles/dark/private-message-button.mcssView
@@ -1,0 +1,6 @@
1+PrivateMessageButton {
2+ margin-bottom: 10px
3+ :hover {
4+ background: #ceab2f
5+ }
6+}
styles/light/compose.mcssView
@@ -57,8 +57,22 @@
5757 background: #fafafa
5858
5959 padding: .4rem
6060
61+ button {
62+ -private {
63+ color: #8a6610;
64+ background: #f3e7ac;
65+ border-color: #f3e7ac;
66+
67+ :hover {
68+ color: #ffffff
69+ background-color: #8a6610
70+ border-color: #8a6610
71+ }
72+ }
73+ }
74+
6175 input[type="file"] {
6276 padding: .5rem 0
6377
6478 width: 95px
styles/light/private-message-button.mcssView
@@ -1,0 +1,7 @@
1+PrivateMessageButton {
2+ :hover {
3+ color: #ffffff
4+ background-color: #8a6610
5+ border-color: #8a6610
6+ }
7+}

Built with git-ssb-web