Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
[bg] Use Chrome native way to open page after extension is installed
Browse files Browse the repository at this point in the history
This should resolve rare cases when welcome page was opened again and again for
some users. Fixes #128.
  • Loading branch information
kepi committed May 7, 2020
1 parent bfe681c commit 835cedb
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ var bg = {
}
})
})

/**
* When Eye Dropper is just installed, we want to display nice
* page to user with some instructions
*/
chrome.runtime.onInstalled.addListener((object: chrome.runtime.InstalledDetails) => {
if (object.reason === 'install') {
chrome.tabs.create({
url: '/installed.html',
selected: true,
})
}
})
},
setBadgeColor: function(color: string) {
console.info('Setting badge color to ' + color)
Expand Down Expand Up @@ -415,25 +428,6 @@ var bg = {
})
}
},
/**
* When Eye Dropper is just installed, we want to display nice
* page to user with some instructions
*/
pageInstalled: function() {
// only if we have support for localStorage
if (window.localStorage != null) {
// show installed or updated page
// do not display if localStorage is not supported - we don't want to spam user
if (window.localStorage && !window.localStorage.seenInstalledPage) {
console.info('Just installed: opening installed page in new tab.')
window.localStorage.seenInstalledPage = true
chrome.tabs.create({
url: '/installed.html',
selected: true,
})
}
}
},
/**
* Load history from storage on extension start
*/
Expand Down Expand Up @@ -681,7 +675,6 @@ var bg = {
},
init: function() {
console.group('init')
bg.pageInstalled()
bg.edCb = document.getElementById('edClipboard')
bg.loadSettings()
bg.loadHistory()
Expand Down

0 comments on commit 835cedb

Please sign in to comment.