Commit 77ebdbbbfbc50269768f1aa419845d1a5e03b970
only try to open external ssb links that are valid
Matt McKegg committed on 4/7/2017, 11:56:27 AMParent: efcfee2e9fa683818c4087fda90aa682f3dc12be
Files changed
main-window.js | changed |
modules/app/views.js | changed |
main-window.js | ||
---|---|---|
@@ -8,8 +8,9 @@ | ||
8 | 8 | var catchLinks = require('./lib/catch-links') |
9 | 9 | var insertCss = require('insert-css') |
10 | 10 | var nest = require('depnest') |
11 | 11 | var LatestUpdate = require('./lib/latest-update') |
12 | +var ref = require('ssb-ref') | |
12 | 13 | |
13 | 14 | require('./lib/context-menu-and-spellcheck.js') |
14 | 15 | |
15 | 16 | module.exports = function (config) { |
@@ -88,11 +89,11 @@ | ||
88 | 89 | |
89 | 90 | catchLinks(container, (href, external) => { |
90 | 91 | if (external) { |
91 | 92 | electron.shell.openExternal(href) |
92 | - } else if (href[0] === '&') { | |
93 | + } else if (ref.isBlob(href)) { | |
93 | 94 | electron.shell.openExternal(api.blob.sync.url(href)) |
94 | - } else if (href[0] === '%') { | |
95 | + } else if (ref.isMsg(href)) { | |
95 | 96 | getExternalHandler(href, (err, handler) => { |
96 | 97 | if (err) throw err |
97 | 98 | if (handler) { |
98 | 99 | handler(href) |
modules/app/views.js | ||
---|---|---|
@@ -85,36 +85,40 @@ | ||
85 | 85 | |
86 | 86 | function loadView (view) { |
87 | 87 | if (!views.has(view)) { |
88 | 88 | 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) | |
95 | 98 | } |
96 | - views.put(view, page) | |
97 | 99 | } |
98 | 100 | } |
99 | 101 | |
100 | 102 | function setView (view) { |
101 | 103 | loadView(view) |
102 | 104 | |
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 | + } | |
106 | 109 | |
107 | - if (currentView() && lastViewed[currentView()] !== true) { | |
108 | - lastViewed[currentView()] = Date.now() | |
109 | - } | |
110 | + if (currentView() && lastViewed[currentView()] !== true) { | |
111 | + lastViewed[currentView()] = Date.now() | |
112 | + } | |
110 | 113 | |
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 | + } | |
117 | 121 | } |
118 | 122 | } |
119 | 123 | }) |
120 | 124 | } |
Built with git-ssb-web