git ssb

16+

Dominic / patchbay



Commit dd6a5bf5f2c82fb52a866d1576c7f04a83e9678e

Merge pull request #198 from ssbc/memes

MEMES (&-mentions)
mix irving authored on 6/6/2018, 10:36:34 AM
GitHub committed on 6/6/2018, 10:36:34 AM
Parent: 2752aa47e92f4d4bb94db8f41b22062b563703b7
Parent: 3f75d16d86f72aacbf190a7b9eb2229e73978b91

Files changed

app/html/filter.jschanged
app/html/search-bar.jschanged
app/page/settings.jschanged
app/sync/initialise/suggestionCaches.jsadded
message/html/compose.jschanged
package-lock.jsonchanged
package.jsonchanged
app/html/filter.jsView
@@ -140,12 +140,11 @@
140140 h('i', { classList: when(state, 'fa fa-check-square-o', 'fa fa-square-o') })
141141 ])
142142 }
143143
144- const getChannelSuggestions = api.channel.async.suggest()
145144 addSuggest(channelInput, (inputText, cb) => {
146145 if (inputText[0] === '#') {
147- cb(null, getChannelSuggestions(inputText.slice(1)))
146 + api.channel.async.suggest(inputText.slice(1), cb)
148147 }
149148 }, {cls: 'PatchSuggest'})
150149 channelInput.addEventListener('suggestselect', ev => {
151150 const channels = channelInput.value.trim()
@@ -154,12 +153,11 @@
154153
155154 draw()
156155 })
157156
158- const getAboutSuggestions = api.about.async.suggest()
159157 addSuggest(userInput, (inputText, cb) => {
160158 inputText = inputText.replace(/^@/, '')
161- cb(null, getAboutSuggestions(inputText))
159 + api.about.async.suggest(inputText, cb)
162160 }, {cls: 'PatchSuggest'})
163161 userInput.addEventListener('suggestselect', ev => userId.set(ev.detail.id))
164162
165163 function followFilter (msg) {
app/html/search-bar.jsView
@@ -16,13 +16,14 @@
1616
1717 return nest('app.html.searchBar', function searchBar () {
1818 if (_search) return _search
1919
20- const getProfileSuggestions = api.about.async.suggest()
21- const getChannelSuggestions = api.channel.async.suggest()
22-
2320 function goToLocation (location, ev) {
24- if (location[0] == '?') { location = { page: 'search', query: location.substring(1) } } else if (!['@', '#', '%', '&', '/'].includes(location[0])) { location = { page: 'search', query: location } }
21 + if (location[0] === '?') {
22 + location = { page: 'search', query: location.substring(1) }
23 + } else if (!['@', '#', '%', '&', '/'].includes(location[0])) {
24 + location = { page: 'search', query: location }
25 + }
2526
2627 api.app.sync.goTo(location)
2728 if (!ev.ctrlKey) input.blur()
2829 }
@@ -32,9 +33,9 @@
3233 placeholder: '?search, @name, #channel',
3334 'ev-keyup': ev => {
3435 switch (ev.keyCode) {
3536 case 13: // enter
36- goToLocation(input.value.trim(), ev)
37 + goToLocation(input.value.trim(), ev)
3738 return
3839 case 27: // escape
3940 ev.preventDefault()
4041 input.blur()
@@ -63,18 +64,18 @@
6364 addSuggest(input, (inputText, cb) => {
6465 const char = inputText[0]
6566 const word = inputText.slice(1)
6667
67- if (char === '@') cb(null, getProfileSuggestions(word))
68- if (char === '#') cb(null, getChannelSuggestions(word))
68 + if (char === '@') api.about.async.suggest(word, cb)
69 + if (char === '#') api.channel.async.suggest(word, cb)
6970 if (char === '/') cb(null, getPagesSuggestions(word))
7071 }, {cls: 'PatchSuggest'})
7172
7273 // TODO extract
7374 function getPagesSuggestions (word) {
7475 const pages = [
7576 'public', 'private', 'inbox', 'profile', 'notifications', 'settings',
76- 'gatherings', 'chess', 'books'
77 + 'gatherings', 'chess', 'books', 'imageSearch', 'polls'
7778 ]
7879
7980 return pages
8081 .filter(page => ~page.indexOf(word))
app/page/settings.jsView
@@ -13,9 +13,9 @@
1313
1414 exports.create = function (api) {
1515 return nest({
1616 'app.html.menuItem': menuItem,
17- 'app.page.settings': publicPage
17 + 'app.page.settings': settingsPage
1818 })
1919
2020 function menuItem () {
2121 return h('a', {
@@ -23,9 +23,9 @@
2323 'ev-click': () => api.app.sync.goTo({ page: 'settings' })
2424 }, '/settings')
2525 }
2626
27- function publicPage (location) {
27 + function settingsPage (location) {
2828 return h('SettingsPage', { title: '/settings' }, [
2929 h('div.container', [
3030 h('h1', 'Settings'),
3131 api.app.html.settings().map(setting => {
app/sync/initialise/suggestionCaches.jsView
@@ -1,0 +1,17 @@
1 +const nest = require('depnest')
2 +
3 +exports.gives = nest('app.sync.initialise')
4 +
5 +exports.needs = nest({
6 + 'about.async.suggest': 'first',
7 + 'channel.async.suggest': 'first'
8 +})
9 +
10 +exports.create = function (api) {
11 + return nest('app.sync.initialise', init)
12 +
13 + function init () {
14 + api.about.async.suggest()
15 + api.channel.async.suggest()
16 + }
17 +}
message/html/compose.jsView
@@ -9,8 +9,9 @@
99 exports.needs = nest({
1010 'about.async.suggest': 'first',
1111 'channel.async.suggest': 'first',
1212 'emoji.async.suggest': 'first',
13 + 'meme.async.suggest': 'first',
1314 'blob.html.input': 'first',
1415 'message.html.confirm': 'first',
1516 'drafts.sync.get': 'first',
1617 'drafts.sync.set': 'first',
@@ -39,12 +40,8 @@
3940 var textAreaFocused = Value(false)
4041 var focused = computed([channelInputFocused, textAreaFocused], (a, b) => a || b)
4142 var hasContent = Value(false)
4243
43- var getProfileSuggestions = api.about.async.suggest()
44- var getChannelSuggestions = api.channel.async.suggest()
45- var getEmojiSuggestions = api.emoji.async.suggest()
46-
4744 var blurTimeout = null
4845
4946 var expanded = computed([shrink, focused, hasContent], (shrink, focused, hasContent) => {
5047 if (!shrink || hasContent) return true
@@ -152,22 +149,23 @@
152149 composer.addQuote = function (data) {
153150 try {
154151 if (typeof data.content.text === 'string') {
155152 var text = data.content.text
156- textArea.value += '> ' + text.replace(/\r\n|\r|\n/g,'\n> ') + '\r\n\n'
153 + textArea.value += '> ' + text.replace(/\r\n|\r|\n/g, '\n> ') + '\r\n\n'
157154 hasContent.set(!!textArea.value)
158155 }
159- } catch(err) {
156 + } catch (err) {
160157 // object not have text or content
161158 }
162159 }
163160
164- if (location.action == 'quote')
161 + if (location.action == 'quote') {
165162 composer.addQuote(location.value)
163 + }
166164
167165 addSuggest(channelInput, (inputText, cb) => {
168166 if (inputText[0] === '#') {
169- cb(null, getChannelSuggestions(inputText.slice(1)))
167 + cb(null, api.channel.async.suggest(inputText.slice(1)))
170168 }
171169 }, {cls: 'PatchSuggest'})
172170 channelInput.addEventListener('suggestselect', ev => {
173171 channelInput.value = ev.detail.id // HACK : this over-rides the markdown value
@@ -176,11 +174,12 @@
176174 addSuggest(textArea, (inputText, cb) => {
177175 const char = inputText[0]
178176 const wordFragment = inputText.slice(1)
179177
180- if (char === '@') cb(null, getProfileSuggestions(wordFragment, feedIdsInThread))
181- if (char === '#') cb(null, getChannelSuggestions(wordFragment))
182- if (char === ':') cb(null, getEmojiSuggestions(wordFragment))
178 + if (char === '@') api.about.async.suggest(wordFragment, feedIdsInThread, cb)
179 + if (char === '#') api.channel.async.suggest(wordFragment, cb)
180 + if (char === ':') api.emoji.async.suggest(wordFragment, cb)
181 + if (char === '&') api.meme.async.suggest(wordFragment, cb)
183182 }, {cls: 'PatchSuggest'})
184183
185184 return composer
186185
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 358146 bytes
New file size: 357146 bytes
package.jsonView
@@ -60,9 +60,9 @@
6060 "patch-history": "^1.0.0",
6161 "patch-hub": "^1.1.0",
6262 "patch-inbox": "^1.0.2",
6363 "patch-settings": "^1.1.1",
64- "patch-suggest": "^1.1.0",
64 + "patch-suggest": "^2.0.0",
6565 "patchbay-book": "^1.0.6",
6666 "patchbay-gatherings": "^2.0.0",
6767 "patchbay-poll": "^1.0.1",
6868 "patchcore": "^1.26.1",
@@ -72,9 +72,9 @@
7272 "pull-scroll": "^1.0.9",
7373 "pull-stream": "^3.6.8",
7474 "read-directory": "^2.1.1",
7575 "require-style": "^1.0.1",
76- "scuttle-blog": "^1.0.0",
76 + "scuttle-blog": "^1.0.1",
7777 "scuttlebot": "^11.3.0",
7878 "setimmediate": "^1.0.5",
7979 "ssb-about": "^0.1.2",
8080 "ssb-backlinks": "^0.7.1",

Built with git-ssb-web