Commit 3a294e357e15360aded899e2d83d79b4e4c584ea
add "Send Private Message" button to profile page
fixes #584Matt McKegg committed on 9/30/2017, 6:17:26 AM
Parent: 84f42d561913f861b364caecc35050feadc23744
Files changed
locales/en.json | ||
---|---|---|
@@ -136,6 +136,9 @@ | ||
136 | 136 | "Close": "Close", |
137 | 137 | "New Message": "New Message", |
138 | 138 | "unsubscribed from ": "unsubscribed from ", |
139 | 139 | "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.js | ||
---|---|---|
@@ -22,9 +22,9 @@ | ||
22 | 22 | exports.gives = nest('message.html.compose') |
23 | 23 | |
24 | 24 | exports.create = function (api) { |
25 | 25 | 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) { | |
27 | 27 | var files = [] |
28 | 28 | var filesById = {} |
29 | 29 | var focused = Value(false) |
30 | 30 | var hasContent = Value(false) |
@@ -96,10 +96,16 @@ | ||
96 | 96 | } |
97 | 97 | |
98 | 98 | var publishBtn = h('button', { |
99 | 99 | 'ev-click': publish, |
100 | + classList: [ | |
101 | + when(isPrivate, '-private') | |
102 | + ], | |
100 | 103 | disabled: publishing |
101 | - }, when(publishing, i18n('Publishing...'), i18n('Publish'))) | |
104 | + }, when(publishing, | |
105 | + i18n('Publishing...'), | |
106 | + when(isPrivate, i18n('Publish Privately'), i18n('Publish')) | |
107 | + )) | |
102 | 108 | |
103 | 109 | var actions = h('section.actions', [ |
104 | 110 | fileInput, |
105 | 111 | publishBtn |
@@ -119,8 +125,13 @@ | ||
119 | 125 | composer.focus = function () { |
120 | 126 | textArea.focus() |
121 | 127 | } |
122 | 128 | |
129 | + composer.setText = function (value) { | |
130 | + textArea.value = value | |
131 | + hasContent.set(!!textArea.value) | |
132 | + } | |
133 | + | |
123 | 134 | addSuggest(textArea, (inputText, cb) => { |
124 | 135 | if (inputText[0] === '@') { |
125 | 136 | cb(null, getProfileSuggestions(inputText.slice(1))) |
126 | 137 | } else if (inputText[0] === '#') { |
modules/message/sheet/likes.js | ||
---|---|---|
@@ -9,9 +9,9 @@ | ||
9 | 9 | 'profile.obs.rank': 'first', |
10 | 10 | 'about.html.image': 'first', |
11 | 11 | 'about.obs.name': 'first', |
12 | 12 | 'app.navigate': 'first', |
13 | - 'intl.sync.i18n': 'first', | |
13 | + 'intl.sync.i18n': 'first' | |
14 | 14 | }) |
15 | 15 | |
16 | 16 | exports.gives = nest('message.sheet.likes') |
17 | 17 |
modules/page/html/render/private.js | ||
---|---|---|
@@ -6,30 +6,42 @@ | ||
6 | 6 | 'feed.pull.private': 'first', |
7 | 7 | 'message.html.compose': 'first', |
8 | 8 | 'keys.sync.id': 'first', |
9 | 9 | 'intl.sync.i18n': 'first', |
10 | + 'about.obs.name': 'first' | |
10 | 11 | }) |
11 | 12 | |
12 | 13 | exports.gives = nest('page.html.render') |
13 | 14 | |
14 | 15 | exports.create = function (api) { |
15 | - const i18n = api.intl.sync.i18n | |
16 | 16 | return nest('page.html.render', function channel (path) { |
17 | 17 | if (path !== '/private') return |
18 | 18 | |
19 | + const i18n = api.intl.sync.i18n | |
19 | 20 | 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 | + }) | |
32 | 32 | |
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 | |
34 | 46 | }) |
35 | 47 | } |
modules/page/html/render/profile.js | ||
---|---|---|
@@ -22,8 +22,9 @@ | ||
22 | 22 | 'keys.sync.id': 'first', |
23 | 23 | 'sheet.display': 'first', |
24 | 24 | 'profile.obs.rank': 'first', |
25 | 25 | 'profile.sheet.edit': 'first', |
26 | + 'app.navigate': 'first', | |
26 | 27 | 'contact.obs': { |
27 | 28 | followers: 'first', |
28 | 29 | following: 'first' |
29 | 30 | }, |
@@ -177,8 +178,9 @@ | ||
177 | 178 | h('div.main', [ |
178 | 179 | feedView |
179 | 180 | ]), |
180 | 181 | h('div.side.-right', [ |
182 | + h('button PrivateMessageButton', {'ev-click': () => api.app.navigate('/private', {compose: {to: id}})}, i18n('Send Private Message')), | |
181 | 183 | when(friendsLoaded, |
182 | 184 | h('div', [ |
183 | 185 | renderContactBlock(i18n('Friends'), friends, yourFollows), |
184 | 186 | renderContactBlock(i18n('Followers'), followers, yourFollows), |
styles/dark/compose.mcss | ||
---|---|---|
@@ -110,8 +110,13 @@ | ||
110 | 110 | button { |
111 | 111 | :hover { |
112 | 112 | background: #6f74e5 |
113 | 113 | } |
114 | + -private { | |
115 | + :hover { | |
116 | + background: #ceab2f | |
117 | + } | |
118 | + } | |
114 | 119 | } |
115 | 120 | } |
116 | 121 | |
117 | 122 | -expanded { |
styles/dark/private-message-button.mcss | ||
---|---|---|
@@ -1,0 +1,6 @@ | ||
1 | +PrivateMessageButton { | |
2 | + margin-bottom: 10px | |
3 | + :hover { | |
4 | + background: #ceab2f | |
5 | + } | |
6 | +} |
styles/light/compose.mcss | ||
---|---|---|
@@ -57,8 +57,22 @@ | ||
57 | 57 | background: #fafafa |
58 | 58 | |
59 | 59 | padding: .4rem |
60 | 60 | |
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 | + | |
61 | 75 | input[type="file"] { |
62 | 76 | padding: .5rem 0 |
63 | 77 | |
64 | 78 | width: 95px |
Built with git-ssb-web