@@ -7,12 +7,18 @@ import Toolbar from '@mui/material/Toolbar';
77import Box from '@mui/material/Box' ;
88import { BrowserRouter , Routes , Route } from 'react-router-dom' ;
99import { type } from '@tauri-apps/api/os' ;
10+ import Alert from '@mui/material/Alert' ;
11+ import Snackbar from '@mui/material/Snackbar' ;
12+ import Button from '@mui/material/Button' ;
13+ import Typography from '@mui/material/Typography' ;
1014import { MainContext } from '../../contexts/MainContextProvider' ;
1115import ThemeSelector from '../../utils/ThemeSelector' ;
1216import TopBar from '../TopBar' ;
1317import ClippedDrawer from '../ClippedDrawer' ;
1418import UpdateDialog from '../UpdateDialog' ;
15- import { openWebSite , setError , setUpdate } from '../../reducers/MainReducer/Actions' ;
19+ import {
20+ openWebSite , setError , setLoading , setUpdate ,
21+ } from '../../reducers/MainReducer/Actions' ;
1622import Updater from '../../utils/Updater' ;
1723import AlertDialog from '../AlertDialog' ;
1824import packageJson from '../../../package.json' ;
@@ -29,10 +35,10 @@ const NotFound = lazy(() => import('../../routes/NotFound'));
2935const App = ( ) => {
3036 const [ state , d1 ] = useContext ( MainContext ) ;
3137 const {
32- themeIndex, themeType, update, languageIndex, autoUpdate, error,
38+ themeIndex, themeType, update, languageIndex, autoUpdate, error, loading ,
3339 } = state ;
3440
35- const [ loading , setLoading ] = useState ( false ) ;
41+ const [ snackOpen , setSnackOpen ] = useState ( false ) ;
3642 const language = state . languages [ languageIndex ] ;
3743
3844 const color = ThemeSelector ( themeIndex ) ;
@@ -44,14 +50,6 @@ const App = () => {
4450 } ,
4551 } ) ;
4652
47- /**
48- * Open a website
49- * @param website The website that needs to be opened
50- */
51- const openWebsite = ( website ) => {
52- d1 ( openWebSite ( website ) ) ;
53- } ;
54-
5553 /**
5654 * Check for updates
5755 */
@@ -77,7 +75,7 @@ const App = () => {
7775 d1 ( setError ( e ) ) ;
7876 } )
7977 . finally ( ( ) => {
80- setLoading ( false ) ;
78+ d1 ( setLoading ( false ) ) ;
8179 } ) ;
8280 } ;
8381
@@ -88,10 +86,21 @@ const App = () => {
8886 d1 ( setError ( null ) ) ;
8987 } ;
9088
89+ /**
90+ * Close the snack bar
91+ */
92+ const closeSnack = ( ) => {
93+ setSnackOpen ( false ) ;
94+ } ;
95+
9196 useEffect ( ( ) => {
9297 // eslint-disable-next-line no-underscore-dangle
93- if ( autoUpdate && window . __TAURI__ ) {
94- checkForUpdates ( ) ;
98+ if ( window . __TAURI__ ) {
99+ if ( autoUpdate ) {
100+ checkForUpdates ( ) ;
101+ }
102+ } else {
103+ setSnackOpen ( true ) ;
95104 }
96105 } , [ ] ) ;
97106
@@ -131,7 +140,7 @@ const App = () => {
131140 < UpdateDialog
132141 downloadUrl = { update . updateUrl }
133142 infoUrl = { update . infoUrl }
134- openWebsite = { openWebsite }
143+ openWebsite = { openWebSite }
135144 newVersion = { update . version }
136145 onClose = { ( ) => d1 ( setUpdate ( null ) ) }
137146 updateAvailable = { language . updateAvailable }
@@ -141,6 +150,20 @@ const App = () => {
141150 cancel = { language . cancel }
142151 />
143152 ) : null }
153+ < Snackbar open = { snackOpen } onClose = { closeSnack } >
154+ < Alert onClose = { closeSnack } severity = "info" sx = { { width : '100%' } } >
155+ < Typography >
156+ { language . downloadApp }
157+ </ Typography >
158+ < Button
159+ onClick = { ( ) => window . open ( 'https://codedead.com/software/advanced-passgen' ) }
160+ size = "small"
161+ color = "secondary"
162+ >
163+ { language . download }
164+ </ Button >
165+ </ Alert >
166+ </ Snackbar >
144167 </ BrowserRouter >
145168 </ ThemeProvider >
146169 ) ;
0 commit comments