git ssb

10+

Matt McKegg / patchwork



Commit 44e159185766b6bf908bd2c7a87bf77e7975e221

use latest ssb-ref and patchcore, support queries on all ref types

Matt McKegg committed on 4/20/2018, 9:31:50 AM
Parent: 5ac42c7db6e5b1423e1c1d1e1bda70030a362981

Files changed

main-window.jschanged
modules/message/html/compose.jschanged
package-lock.jsonchanged
package.jsonchanged
main-window.jsView
@@ -15,9 +15,9 @@
1515
1616 module.exports = function (config) {
1717 var sockets = combine(
1818 overrideConfig(config),
19- addCommand('app.navigate', setView),
19+ addCommand('app.navigate', navigate),
2020 require('./modules'),
2121 require('./plugs'),
2222 require('patch-settings'),
2323 require('patchcore'),
@@ -139,22 +139,13 @@
139139
140140 var previewElement = api.app.linkPreview(container, 500)
141141
142142 catchLinks(container, (href, external, anchor) => {
143+ if (!href) return
143144 if (external) {
144145 electron.shell.openExternal(href)
145- } else if (href && href.startsWith('&')) { // (ref.isBlob(href)) {
146- electron.shell.openExternal(api.blob.sync.url(href))
147- } else if (ref.isMsg(href)) {
148- getExternalHandler(href, (err, handler) => {
149- if (!err && handler) {
150- handler(href)
151- } else {
152- api.app.navigate(href, anchor)
153- }
154- })
155146 } else {
156- api.app.navigate(href, anchor)
147+ api.app.navigate(href)
157148 }
158149 })
159150
160151 return [container, previewElement]
@@ -169,26 +160,26 @@
169160 label: i18n('Channels'),
170161 submenu: [
171162 { label: i18n('Browse All'),
172163 click () {
173- setView('/channels')
164+ navigate('/channels')
174165 }
175166 },
176167 {type: 'separator'}
177168 ].concat(channels.map(channel => {
178169 return {
179170 label: `#${channel}`,
180171 click () {
181- setView(`#${channel}`)
172+ navigate(`#${channel}`)
182173 }
183174 }
184175 }))
185176 }
186177 } else {
187178 return {
188179 label: i18n('Browse Channels'),
189180 click () {
190- setView('/channels')
181+ navigate('/channels')
191182 }
192183 }
193184 }
194185 }
@@ -206,9 +197,9 @@
206197 } else {
207198 return {
208199 label: item[0],
209200 click () {
210- setView(item[1])
201+ navigate(item[1])
211202 }
212203 }
213204 }
214205 }))
@@ -222,18 +213,31 @@
222213 }, title)
223214 return element
224215 }
225216
226- function setView (href, anchor) {
227- previewElement.cancel()
228- views.setView(href, anchor)
217+ function navigate (href, anchor) {
218+ if (typeof href !== 'string') return false
219+ getExternalHandler(href, (err, handler) => {
220+ if (!err && handler) {
221+ handler(href)
222+ } else {
223+ // no external handler found, use page.html.render
224+ previewElement.cancel()
225+ views.setView(href, anchor)
226+ }
227+ })
229228 }
230229
231- function getExternalHandler (key, cb) {
232- api.sbot.async.get(key, function (err, value) {
233- if (err) return cb(err)
234- cb(null, api.app.sync.externalHandler({key, value}))
235- })
230+ function getExternalHandler (href, cb) {
231+ var link = ref.parseLink(href)
232+ if (link && ref.isMsg(link.link)) {
233+ api.sbot.async.get(link.link, function (err, value) {
234+ if (err) return cb(err)
235+ cb(null, api.app.sync.externalHandler({key: link.link, value, query: link.query}))
236+ })
237+ } else {
238+ cb()
239+ }
236240 }
237241
238242 function tab (name, view) {
239243 var instance = views.get(view)
modules/message/html/compose.jsView
@@ -78,10 +78,10 @@
7878 }
7979
8080 files.push(file)
8181
82- var blob = ref.parseBlob(file.link)
83- filesById[blob.id] = file
82+ var parsed = ref.parseLink(file.link)
83+ filesById[parsed.link] = file
8484
8585 var embed = isEmbeddable(file.type) ? '!' : ''
8686 var pos = textArea.selectionStart
8787 var before = textArea.value.slice(0, pos)
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 295248 bytes
New file size: 294501 bytes
package.jsonView
@@ -42,9 +42,9 @@
4242 "mutant": "^3.21.2",
4343 "mutant-pull-reduce": "^1.1.0",
4444 "obv": "0.0.1",
4545 "patch-settings": "~1.1.0",
46- "patchcore": "github:ssbc/patchcore#embed-audio-video",
46+ "patchcore": "~1.26.0",
4747 "pull-abortable": "^4.1.0",
4848 "pull-cat": "^1.1.11",
4949 "pull-defer": "^0.2.2",
5050 "pull-file": "~1.0.0",
@@ -70,9 +70,9 @@
7070 "ssb-mentions": "github:ssbc/ssb-mentions#private-blobs",
7171 "ssb-msgs": "^5.2.0",
7272 "ssb-private": "~0.1.4",
7373 "ssb-query": "^1.0.0",
74- "ssb-ref": "github:ssbc/ssb-ref#secret-blobs",
74+ "ssb-ref": "^2.11.0",
7575 "ssb-search": "~1.1.1",
7676 "ssb-sort": "^1.0.0",
7777 "ssb-ws": "~2.1.1",
7878 "standard": "^11.0.1",

Built with git-ssb-web