33import { createContextMenus } from './exports.js'
44
55chrome . runtime . onInstalled . addListener ( onInstalled )
6-
76chrome . contextMenus . onClicked . addListener ( contextMenuClick )
87
98chrome . notifications . onClicked . addListener ( ( notificationId ) => {
@@ -14,16 +13,35 @@ chrome.notifications.onClicked.addListener((notificationId) => {
1413/**
1514 * Init Context Menus and Options
1615 * @function onInstalled
16+ * @param {InstalledDetails } details
1717 */
18- export async function onInstalled ( ) {
19- console . log ( 'onInstalled' )
18+ async function onInstalled ( details ) {
19+ console . log ( 'onInstalled:' , details )
2020 let { options } = await chrome . storage . sync . get ( [ 'options' ] )
21- options = options || { contextMenu : true , recentFiles : '10' }
21+ options = options || {
22+ contextMenu : true ,
23+ recentFiles : '10' ,
24+ showUpdate : false ,
25+ }
2226 console . log ( 'options:' , options )
2327 await chrome . storage . sync . set ( { options } )
2428 if ( options . contextMenu ) {
2529 createContextMenus ( )
2630 }
31+ if ( details . reason === 'install' ) {
32+ const url = chrome . runtime . getURL ( '/html/options.html' )
33+ await chrome . tabs . create ( { active : true , url } )
34+ } else if ( options . showUpdate && details . reason === 'update' ) {
35+ const manifest = chrome . runtime . getManifest ( )
36+ if ( manifest . version !== details . previousVersion ) {
37+ const url = `https://github.com/django-files/web-extension/releases/tag/${ manifest . version } `
38+ console . log ( `url: ${ url } ` )
39+ await chrome . tabs . create ( { active : true , url } )
40+ }
41+ }
42+ chrome . runtime . setUninstallURL (
43+ 'https://github.com/django-files/web-extension/issues'
44+ )
2745}
2846
2947/**
@@ -108,7 +126,7 @@ async function sendNotification(title, text, id = '', timeout = 10) {
108126 console . log ( `sendNotification: ${ id || 'randomID' } : ${ title } - ${ text } ` )
109127 const options = {
110128 type : 'basic' ,
111- iconUrl : chrome . runtime . getURL ( 'images/logo128 .png' ) ,
129+ iconUrl : chrome . runtime . getURL ( 'media/logo96 .png' ) ,
112130 title : title ,
113131 message : text ,
114132 }
0 commit comments