Files: e6df29b999257c928b0fe5316875680a479dba2e / app / sync / initialize / clickHandler.js
594 bytesRaw
1 | const nest = require('depnest') |
2 | const openExternal = require('open-external') |
3 | |
4 | exports.gives = nest('app.sync.initialize') |
5 | |
6 | exports.needs = nest({ |
7 | 'app.async.catchLinkClick': 'first', |
8 | 'history.sync.push': 'first' |
9 | }) |
10 | |
11 | exports.create = (api) => { |
12 | return nest({ |
13 | 'app.sync.initialize': function initializeClickHandling () { |
14 | console.log('> initialise: clickHandler') |
15 | const target = document.body |
16 | |
17 | api.app.async.catchLinkClick(target, (link, { isExternal }) => { |
18 | if (isExternal) return openExternal(link) |
19 | |
20 | api.history.sync.push(link) |
21 | }) |
22 | } |
23 | }) |
24 | } |
25 |
Built with git-ssb-web