Skip to content

Commit 3910d73

Browse files
committed
feat: reload app if a new version is detected
1 parent d65c7af commit 3910d73

File tree

1 file changed

+9
-4
lines changed
  • src/frontend/components/UI/AppVersion

1 file changed

+9
-4
lines changed

src/frontend/components/UI/AppVersion/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import React, { useEffect, useState } from 'react'
22

33
const storage = window.localStorage
4-
let lastVersion = storage.getItem('last_version')?.replaceAll('"', '')
5-
if (lastVersion === undefined) {
6-
lastVersion = ''
7-
}
4+
const lastVersion = storage.getItem('last_version')?.replaceAll('"', '')
85

96
export default function AppVersion() {
107
const [appVersion, setAppVersion] = useState(lastVersion)
118

129
useEffect(() => {
1310
window.api.getAppVersion().then((version) => {
11+
if (version !== lastVersion) {
12+
window.api.logInfo(
13+
`Updated to a new version, reloading the MetaMask extension. Old version: ${lastVersion}, new version: ${version}`
14+
)
15+
window.api.reloadForMM()
16+
} else {
17+
window.api.logInfo('No new version detected. Wont reload the app')
18+
}
1419
storage.setItem('last_version', JSON.stringify(version))
1520
setAppVersion(version)
1621
})

0 commit comments

Comments
 (0)