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.js | changed |
app/html/search-bar.js | changed |
app/page/settings.js | changed |
app/sync/initialise/suggestionCaches.js | added |
message/html/compose.js | changed |
package-lock.json | changed |
package.json | changed |
app/html/filter.js | ||
---|---|---|
@@ -140,12 +140,11 @@ | ||
140 | 140 … | h('i', { classList: when(state, 'fa fa-check-square-o', 'fa fa-square-o') }) |
141 | 141 … | ]) |
142 | 142 … | } |
143 | 143 … | |
144 | - const getChannelSuggestions = api.channel.async.suggest() | |
145 | 144 … | addSuggest(channelInput, (inputText, cb) => { |
146 | 145 … | if (inputText[0] === '#') { |
147 | - cb(null, getChannelSuggestions(inputText.slice(1))) | |
146 … | + api.channel.async.suggest(inputText.slice(1), cb) | |
148 | 147 … | } |
149 | 148 … | }, {cls: 'PatchSuggest'}) |
150 | 149 … | channelInput.addEventListener('suggestselect', ev => { |
151 | 150 … | const channels = channelInput.value.trim() |
@@ -154,12 +153,11 @@ | ||
154 | 153 … | |
155 | 154 … | draw() |
156 | 155 … | }) |
157 | 156 … | |
158 | - const getAboutSuggestions = api.about.async.suggest() | |
159 | 157 … | addSuggest(userInput, (inputText, cb) => { |
160 | 158 … | inputText = inputText.replace(/^@/, '') |
161 | - cb(null, getAboutSuggestions(inputText)) | |
159 … | + api.about.async.suggest(inputText, cb) | |
162 | 160 … | }, {cls: 'PatchSuggest'}) |
163 | 161 … | userInput.addEventListener('suggestselect', ev => userId.set(ev.detail.id)) |
164 | 162 … | |
165 | 163 … | function followFilter (msg) { |
app/html/search-bar.js | |||
---|---|---|---|
@@ -16,13 +16,14 @@ | |||
16 | 16 … | ||
17 | 17 … | return nest('app.html.searchBar', function searchBar () { | |
18 | 18 … | if (_search) return _search | |
19 | 19 … | ||
20 | - const getProfileSuggestions = api.about.async.suggest() | ||
21 | - const getChannelSuggestions = api.channel.async.suggest() | ||
22 | - | ||
23 | 20 … | 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 … | + } | ||
25 | 26 … | ||
26 | 27 … | api.app.sync.goTo(location) | |
27 | 28 … | if (!ev.ctrlKey) input.blur() | |
28 | 29 … | } | |
@@ -32,9 +33,9 @@ | |||
32 | 33 … | placeholder: '?search, @name, #channel', | |
33 | 34 … | 'ev-keyup': ev => { | |
34 | 35 … | switch (ev.keyCode) { | |
35 | 36 … | case 13: // enter | |
36 | - goToLocation(input.value.trim(), ev) | ||
37 … | + goToLocation(input.value.trim(), ev) | ||
37 | 38 … | return | |
38 | 39 … | case 27: // escape | |
39 | 40 … | ev.preventDefault() | |
40 | 41 … | input.blur() | |
@@ -63,18 +64,18 @@ | |||
63 | 64 … | addSuggest(input, (inputText, cb) => { | |
64 | 65 … | const char = inputText[0] | |
65 | 66 … | const word = inputText.slice(1) | |
66 | 67 … | ||
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) | ||
69 | 70 … | if (char === '/') cb(null, getPagesSuggestions(word)) | |
70 | 71 … | }, {cls: 'PatchSuggest'}) | |
71 | 72 … | ||
72 | 73 … | // TODO extract | |
73 | 74 … | function getPagesSuggestions (word) { | |
74 | 75 … | const pages = [ | |
75 | 76 … | 'public', 'private', 'inbox', 'profile', 'notifications', 'settings', | |
76 | - 'gatherings', 'chess', 'books' | ||
77 … | + 'gatherings', 'chess', 'books', 'imageSearch', 'polls' | ||
77 | 78 … | ] | |
78 | 79 … | ||
79 | 80 … | return pages | |
80 | 81 … | .filter(page => ~page.indexOf(word)) |
app/page/settings.js | ||
---|---|---|
@@ -13,9 +13,9 @@ | ||
13 | 13 … | |
14 | 14 … | exports.create = function (api) { |
15 | 15 … | return nest({ |
16 | 16 … | 'app.html.menuItem': menuItem, |
17 | - 'app.page.settings': publicPage | |
17 … | + 'app.page.settings': settingsPage | |
18 | 18 … | }) |
19 | 19 … | |
20 | 20 … | function menuItem () { |
21 | 21 … | return h('a', { |
@@ -23,9 +23,9 @@ | ||
23 | 23 … | 'ev-click': () => api.app.sync.goTo({ page: 'settings' }) |
24 | 24 … | }, '/settings') |
25 | 25 … | } |
26 | 26 … | |
27 | - function publicPage (location) { | |
27 … | + function settingsPage (location) { | |
28 | 28 … | return h('SettingsPage', { title: '/settings' }, [ |
29 | 29 … | h('div.container', [ |
30 | 30 … | h('h1', 'Settings'), |
31 | 31 … | api.app.html.settings().map(setting => { |
app/sync/initialise/suggestionCaches.js | ||
---|---|---|
@@ -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.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 … | exports.needs = nest({ |
10 | 10 … | 'about.async.suggest': 'first', |
11 | 11 … | 'channel.async.suggest': 'first', |
12 | 12 … | 'emoji.async.suggest': 'first', |
13 … | + 'meme.async.suggest': 'first', | |
13 | 14 … | 'blob.html.input': 'first', |
14 | 15 … | 'message.html.confirm': 'first', |
15 | 16 … | 'drafts.sync.get': 'first', |
16 | 17 … | 'drafts.sync.set': 'first', |
@@ -39,12 +40,8 @@ | ||
39 | 40 … | var textAreaFocused = Value(false) |
40 | 41 … | var focused = computed([channelInputFocused, textAreaFocused], (a, b) => a || b) |
41 | 42 … | var hasContent = Value(false) |
42 | 43 … | |
43 | - var getProfileSuggestions = api.about.async.suggest() | |
44 | - var getChannelSuggestions = api.channel.async.suggest() | |
45 | - var getEmojiSuggestions = api.emoji.async.suggest() | |
46 | - | |
47 | 44 … | var blurTimeout = null |
48 | 45 … | |
49 | 46 … | var expanded = computed([shrink, focused, hasContent], (shrink, focused, hasContent) => { |
50 | 47 … | if (!shrink || hasContent) return true |
@@ -152,22 +149,23 @@ | ||
152 | 149 … | composer.addQuote = function (data) { |
153 | 150 … | try { |
154 | 151 … | if (typeof data.content.text === 'string') { |
155 | 152 … | 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' | |
157 | 154 … | hasContent.set(!!textArea.value) |
158 | 155 … | } |
159 | - } catch(err) { | |
156 … | + } catch (err) { | |
160 | 157 … | // object not have text or content |
161 | 158 … | } |
162 | 159 … | } |
163 | 160 … | |
164 | - if (location.action == 'quote') | |
161 … | + if (location.action == 'quote') { | |
165 | 162 … | composer.addQuote(location.value) |
163 … | + } | |
166 | 164 … | |
167 | 165 … | addSuggest(channelInput, (inputText, cb) => { |
168 | 166 … | if (inputText[0] === '#') { |
169 | - cb(null, getChannelSuggestions(inputText.slice(1))) | |
167 … | + cb(null, api.channel.async.suggest(inputText.slice(1))) | |
170 | 168 … | } |
171 | 169 … | }, {cls: 'PatchSuggest'}) |
172 | 170 … | channelInput.addEventListener('suggestselect', ev => { |
173 | 171 … | channelInput.value = ev.detail.id // HACK : this over-rides the markdown value |
@@ -176,11 +174,12 @@ | ||
176 | 174 … | addSuggest(textArea, (inputText, cb) => { |
177 | 175 … | const char = inputText[0] |
178 | 176 … | const wordFragment = inputText.slice(1) |
179 | 177 … | |
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) | |
183 | 182 … | }, {cls: 'PatchSuggest'}) |
184 | 183 … | |
185 | 184 … | return composer |
186 | 185 … |
package-lock.json | ||
---|---|---|
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.json | ||
---|---|---|
@@ -60,9 +60,9 @@ | ||
60 | 60 … | "patch-history": "^1.0.0", |
61 | 61 … | "patch-hub": "^1.1.0", |
62 | 62 … | "patch-inbox": "^1.0.2", |
63 | 63 … | "patch-settings": "^1.1.1", |
64 | - "patch-suggest": "^1.1.0", | |
64 … | + "patch-suggest": "^2.0.0", | |
65 | 65 … | "patchbay-book": "^1.0.6", |
66 | 66 … | "patchbay-gatherings": "^2.0.0", |
67 | 67 … | "patchbay-poll": "^1.0.1", |
68 | 68 … | "patchcore": "^1.26.1", |
@@ -72,9 +72,9 @@ | ||
72 | 72 … | "pull-scroll": "^1.0.9", |
73 | 73 … | "pull-stream": "^3.6.8", |
74 | 74 … | "read-directory": "^2.1.1", |
75 | 75 … | "require-style": "^1.0.1", |
76 | - "scuttle-blog": "^1.0.0", | |
76 … | + "scuttle-blog": "^1.0.1", | |
77 | 77 … | "scuttlebot": "^11.3.0", |
78 | 78 … | "setimmediate": "^1.0.5", |
79 | 79 … | "ssb-about": "^0.1.2", |
80 | 80 … | "ssb-backlinks": "^0.7.1", |
Built with git-ssb-web