@@ -6,18 +6,37 @@ import "./index.css";
66// Version checking function
77const checkVersion = ( ) => {
88const currentVersion = __APP_VERSION__ ;
9- const lastVersion = localStorage . getItem ( ' app_version' ) ;
9+ const lastVersion = localStorage . getItem ( " app_version" ) ;
1010
1111if ( lastVersion !== currentVersion ) {
12- localStorage . setItem ( 'app_version' , currentVersion ) ;
13- // Clear cache and reload if version changed
14- if ( 'caches' in window ) {
12+ console . log (
13+ `App version changed from${ lastVersion } to${ currentVersion } , clearing cache...`
14+ ) ;
15+
16+ // Save important settings
17+ const language = localStorage . getItem ( "language" ) ;
18+ const mode = localStorage . getItem ( "mode" ) ;
19+
20+ // Clear all storage
21+ localStorage . clear ( ) ;
22+
23+ // Restore important settings
24+ if ( language ) localStorage . setItem ( "language" , language ) ;
25+ if ( mode ) localStorage . setItem ( "mode" , mode ) ;
26+
27+ // Set new version
28+ localStorage . setItem ( "app_version" , currentVersion ) ;
29+
30+ // Clear cache
31+ if ( "caches" in window ) {
1532caches . keys ( ) . then ( ( names ) => {
16- names . forEach ( name => {
33+ names . forEach ( ( name ) => {
1734caches . delete ( name ) ;
1835} ) ;
1936} ) ;
2037}
38+
39+ // Force reload from server
2140window . location . reload ( true ) ;
2241}
2342} ;