File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { Permissions } from 'src/services/permissions'
15
15
import { Snapshots } from 'src/services/snapshots'
16
16
import { Sidebar } from 'src/services/sidebar'
17
17
import { Info } from 'src/services/info'
18
+ import { versionToInt } from 'src/services/info.actions'
18
19
import { Menu } from 'src/services/menu'
19
20
import { Styles } from 'src/services/styles'
20
21
import { WebReq } from 'src/services/web-req'
@@ -115,6 +116,12 @@ void (async function main() {
115
116
116
117
initToolbarButton ( )
117
118
119
+ browser . runtime . onUpdateAvailable . addListener ( details => {
120
+ const currentVersion = versionToInt ( browser . runtime . getManifest ( ) . version )
121
+ const newVersion = versionToInt ( details . version )
122
+ if ( newVersion <= currentVersion ) browser . runtime . reload ( )
123
+ } )
124
+
118
125
Logs . info ( `Init end: ${ performance . now ( ) - ts } ms` )
119
126
} ) ( )
120
127
Original file line number Diff line number Diff line change @@ -84,3 +84,12 @@ export async function loadCurrentTabInfo(): Promise<void> {
84
84
const tab = await browser . tabs . getCurrent ( )
85
85
Info . currentTabId = tab . id
86
86
}
87
+
88
+ export function versionToInt ( version : string ) : number {
89
+ const parsed = version . split ( '.' ) . map ( n => parseInt ( n ) )
90
+ const major = isNaN ( parsed [ 0 ] ) ? 0 : parsed [ 0 ]
91
+ const minor = isNaN ( parsed [ 1 ] ) ? 0 : parsed [ 1 ]
92
+ const patch = isNaN ( parsed [ 2 ] ) ? 0 : parsed [ 2 ]
93
+ const nightly = isNaN ( parsed [ 3 ] ) ? 0 : parsed [ 3 ]
94
+ return nightly + patch * 1_000 + minor * 1_000_000 + major * 1_000_000_000
95
+ }
You can’t perform that action at this time.
0 commit comments