File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const initPHPSearch = async (language) => {
2020 const key = `search2-${ language } ` ;
2121 const cache = window . localStorage . getItem ( key ) ;
2222
23- if ( ! cache ) {
23+ if ( ( ! cache ) || ( language === 'local' ) ) {
2424 return null ;
2525 }
2626
@@ -48,20 +48,20 @@ const initPHPSearch = async (language) => {
4848 } else {
4949 const response = await fetch ( `/js/search-index.php?lang=${ language } ` ) ;
5050 items = await response . json ( ) ;
51- }
5251
53- try {
54- localStorage . setItem (
55- key ,
56- JSON . stringify ( {
57- data : items ,
58- time : Date . now ( ) ,
59- } ) ,
60- ) ;
61- } catch ( e ) {
62- // Local storage might be full, or other error.
63- // Just continue without caching.
64- console . error ( "Failed to cache search index" , e ) ;
52+ try {
53+ localStorage . setItem (
54+ key ,
55+ JSON . stringify ( {
56+ data : items ,
57+ time : Date . now ( ) ,
58+ } ) ,
59+ ) ;
60+ } catch ( e ) {
61+ // Local storage might be full, or other error.
62+ // Just continue without caching.
63+ console . error ( "Failed to cache search index" , e ) ;
64+ }
6565 }
6666
6767 return items ;
You can’t perform that action at this time.
0 commit comments