git ssb

0+

dangerousbeans / patchwork



forked from Matt McKegg / patchwork

Commit 77ebdbbbfbc50269768f1aa419845d1a5e03b970

only try to open external ssb links that are valid

Matt McKegg committed on 4/7/2017, 11:56:27 AM
Parent: efcfee2e9fa683818c4087fda90aa682f3dc12be

Files changed

main-window.jschanged
modules/app/views.jschanged
main-window.jsView
@@ -8,8 +8,9 @@
88 var catchLinks = require('./lib/catch-links')
99 var insertCss = require('insert-css')
1010 var nest = require('depnest')
1111 var LatestUpdate = require('./lib/latest-update')
12+var ref = require('ssb-ref')
1213
1314 require('./lib/context-menu-and-spellcheck.js')
1415
1516 module.exports = function (config) {
@@ -88,11 +89,11 @@
8889
8990 catchLinks(container, (href, external) => {
9091 if (external) {
9192 electron.shell.openExternal(href)
92- } else if (href[0] === '&') {
93+ } else if (ref.isBlob(href)) {
9394 electron.shell.openExternal(api.blob.sync.url(href))
94- } else if (href[0] === '%') {
95+ } else if (ref.isMsg(href)) {
9596 getExternalHandler(href, (err, handler) => {
9697 if (err) throw err
9798 if (handler) {
9899 handler(href)
modules/app/views.jsView
@@ -85,36 +85,40 @@
8585
8686 function loadView (view) {
8787 if (!views.has(view)) {
8888 var page = renderPage(view)
89- if (page.uniqueKey) {
90- views.keys().forEach(k => {
91- if (views.get(k).uniqueKey === page.uniqueKey) {
92- views.delete(k)
93- }
94- })
89+ if (page) {
90+ if (page.uniqueKey) {
91+ views.keys().forEach(k => {
92+ if (views.get(k).uniqueKey === page.uniqueKey) {
93+ views.delete(k)
94+ }
95+ })
96+ }
97+ views.put(view, page)
9598 }
96- views.put(view, page)
9799 }
98100 }
99101
100102 function setView (view) {
101103 loadView(view)
102104
103- if (lastViewed[view] !== true) {
104- lastViewed[view] = Date.now()
105- }
105+ if (views.has(view)) {
106+ if (lastViewed[view] !== true) {
107+ lastViewed[view] = Date.now()
108+ }
106109
107- if (currentView() && lastViewed[currentView()] !== true) {
108- lastViewed[currentView()] = Date.now()
109- }
110+ if (currentView() && lastViewed[currentView()] !== true) {
111+ lastViewed[currentView()] = Date.now()
112+ }
110113
111- if (view !== currentView()) {
112- canGoForward.set(false)
113- canGoBack.set(true)
114- forwardHistory.length = 0
115- backHistory.push(currentView())
116- currentView.set(view)
114+ if (view !== currentView()) {
115+ canGoForward.set(false)
116+ canGoBack.set(true)
117+ forwardHistory.length = 0
118+ backHistory.push(currentView())
119+ currentView.set(view)
120+ }
117121 }
118122 }
119123 })
120124 }

Built with git-ssb-web