Skip to content

Commit

Permalink
feat: open landing page on first install
Browse files Browse the repository at this point in the history
- also when loaded as a temporary extension to make it easier to dev
  • Loading branch information
lidel authored and fsdiogo committed Sep 10, 2018
1 parent c23c889 commit b2fe74a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions add-on/src/background/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const createIpfsCompanion = require('../lib/ipfs-companion')
const onInstalled = require('../lib/on-installed')

// register onInstalled hook early, otherwise we miss first install event
browser.runtime.onInstalled.addListener(onInstalled)

// init add-on after all libs are loaded
document.addEventListener('DOMContentLoaded', async () => {
Expand Down
14 changes: 14 additions & 0 deletions add-on/src/lib/on-installed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'
/* eslint-env browser */

const browser = require('webextension-polyfill')

module.exports = function onRuntimeInstalled (details) {
console.log('[ipfs-companion] onInstalled event', details)
// details.temporary === run via `npm run firefox`
if (details.reason === 'install' || details.temporary) {
browser.tabs.create({
url: '/dist/landing-pages/welcome/index.html'
})
}
}

0 comments on commit b2fe74a

Please sign in to comment.