Skip to content

Commit 4adbc05

Browse files
committed
Update filebrowser.js
1 parent 367f3be commit 4adbc05

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

filebrowser.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ async function renderSidebarHTML() {
123123
}
124124

125125

126+
const currentTime = new Date().getTime();
127+
126128
// if repo obj dosen't exist
127-
if (!repoObj || !repoObj.defaultBranch) {
129+
if (!repoObj || !repoObj.defaultBranch
130+
|| !repoObj.repoDataExpiration || !repoObj.branchExpiration
131+
|| repoObj.repoDataExpiration < currentTime) {
128132

129133
// get repo obj from git
130134
// and save to modified repos
@@ -1506,8 +1510,20 @@ async function renderBranchMenuHTML(renderAll) {
15061510

15071511
let branchResp;
15081512

1513+
1514+
// get current time
1515+
1516+
let currentDate = new Date();
1517+
const currentTime = currentDate.getTime();
1518+
1519+
currentDate.setDate(currentDate.getDate() + 1);
1520+
const dayFromNow = currentDate.getTime();
1521+
1522+
15091523
// if repo obj exists
1510-
if (repoObj && repoObj.branches) {
1524+
if (repoObj && repoObj.branches &&
1525+
repoObj.branchExpiration &&
1526+
repoObj.branchExpiration >= currentTime) {
15111527

15121528
// get repository branches
15131529
// from repo obj
@@ -1526,7 +1542,9 @@ async function renderBranchMenuHTML(renderAll) {
15261542

15271543
// if branch resp isn't already stored
15281544
// in local storage
1529-
if (!repoObj || !repoObj.branches) {
1545+
if (!repoObj || !repoObj.branches ||
1546+
!repoObj.branchExpiration ||
1547+
repoObj.branchExpiration < currentTime) {
15301548

15311549
// get branches for repository
15321550
branchResp = await git.getBranches(treeLoc);
@@ -1544,6 +1562,10 @@ async function renderBranchMenuHTML(renderAll) {
15441562
// save branch resp in local storage
15451563
updateModRepoBranches(fullName, cleanedResp);
15461564

1565+
// save branch expiration date
1566+
// in local storage
1567+
updateModRepoBranchExpiration(dayFromNow);
1568+
15471569
}
15481570

15491571
}

0 commit comments

Comments
 (0)