Skip to content

Commit

Permalink
feat: graduate out of beta and fix web cache issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Mar 3, 2024
1 parent c9b7747 commit 0c5ca39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"config": {
"app_title": "Phoenix Code Beta",
"app_name_about": "Phoenix Code Beta",
"app_title": "Phoenix Code",
"app_name_about": "Phoenix Code",
"about_icon": "styles/images/phoenix-icon.svg",
"how_to_use_url": "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
"support_url": "https://github.com/phcode-dev/phoenix/discussions",
Expand Down
32 changes: 18 additions & 14 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,20 @@
}
await clearLegacyCache();

const shouldRefreshLess = window.localStorage.getItem(LESS_REFRESH_SCHEDULED_KEY) === 'yes';
if(shouldRefreshLess){
let lessRefreshInterval = setInterval(()=>{
// wait for less to get loaded. less caches css in local storage in production urls
// and might not load new css classes if we don't reset. less doesn't cache in localhost.
if(window.less && less.refresh){
less.refresh(true).finally(()=>{
localStorage.setItem(LESS_REFRESH_SCHEDULED_KEY, "no");
});
clearInterval(lessRefreshInterval);
}
}, 500);
}

const currentCacheName = await _readFileSafe(WEB_CACHE_FILE_PATH);
if(!currentCacheName) {
// fresh install, no cache
Expand All @@ -423,20 +437,10 @@
await window.caches.delete(currentCacheName);
await _writeFileSafe(WEB_CACHE_FILE_PATH, PHOENIX_APP_CACHE_VERSION);
localStorage.setItem(LESS_REFRESH_SCHEDULED_KEY, "yes");
}

const shouldRefreshLess = window.localStorage.getItem(LESS_REFRESH_SCHEDULED_KEY) === 'yes';
if(shouldRefreshLess){
let lessRefreshInterval = setInterval(()=>{
// wait for less to get loaded. less caches css in local storage in production urls
// and might not load new css classes if we don't reset. less doesn't cache in localhost.
if(window.less && less.refresh){
less.refresh(true).finally(()=>{
localStorage.setItem(LESS_REFRESH_SCHEDULED_KEY, "no");
});
clearInterval(lessRefreshInterval);
}
}, 500);
if(!force){
location.reload();
// force reload handlers should reload themselves.
}
}
}
_resetCacheIfNeeded();
Expand Down

0 comments on commit 0c5ca39

Please sign in to comment.