@@ -103,7 +103,7 @@ async function renderSidebarHTML() {
103103
104104
105105 // if repo obj dosen't exist
106- if ( ! repoObj ) {
106+ if ( ! repoObj || ! repoObj . defaultBranch ) {
107107
108108 // get repo obj from git
109109 // and save to modified repos
@@ -202,6 +202,20 @@ async function renderSidebarHTML() {
202202
203203 alert ( 'Hmm... we can\'t find that repo.\nIf it\'s private, try double checking you\'re on the account with access.' ) ;
204204
205+
206+ // get repo obj from local storage
207+ const repoObj = modifiedRepos [ user + '/' + repoName ] ;
208+
209+ // if repo obj exists
210+ if ( repoObj ) {
211+
212+ // delete repo obj from modified repos
213+ deleteModRepo ( user + '/' + repoName ) ;
214+
215+ }
216+
217+
218+ // change location
205219 treeLoc [ 1 ] = '' ;
206220 treeLoc [ 2 ] = '' ;
207221 saveTreeLocLS ( treeLoc ) ;
@@ -276,13 +290,27 @@ async function renderSidebarHTML() {
276290
277291 // if couldn't find branch, show not found screen
278292
279- const defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
293+ // get repo obj from local storage
294+ const repoObj = modifiedRepos [ user + '/' + repoName ] ;
295+ let defaultBranch ;
296+
297+ if ( repoObj && repoObj . defaultBranch ) {
298+
299+ defaultBranch = repoObj . defaultBranch ;
300+
301+ } else {
302+
303+ defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
304+
305+ }
306+
280307
281308 // stop loading
282309 stopLoading ( ) ;
283310
284311 showMessage ( 'Hmm... we can\'t find that branch.' , 5000 ) ;
285312
313+ // add branch to tree
286314 treeLoc [ 1 ] = repo . split ( ':' ) [ 0 ] + ':' + defaultBranch ;
287315 saveTreeLocLS ( treeLoc ) ;
288316
@@ -580,8 +608,11 @@ async function renderSidebarHTML() {
580608 // get rendered repos
581609 let renderedRepos = { } ;
582610
611+ // get all user-owned modified repos
612+ const userModRepos = Object . keys ( modifiedRepos ) . filter ( repo => repo . split ( '/' ) [ 0 ] === loggedUser ) ;
613+
583614 // if repositories exist
584- if ( resp . length > 0 || Object . keys ( modifiedRepos ) . length > 0 ) {
615+ if ( resp . length > 0 || userModRepos . length > 0 ) {
585616
586617 // show search button
587618 searchButton . classList . remove ( 'hidden' ) ;
@@ -620,7 +651,8 @@ async function renderSidebarHTML() {
620651 if ( ! modifiedRepos [ item . full_name ] ) {
621652
622653 // create repo obj
623- repoObj = createRepoObj ( item . full_name , item . default_branch , ( item . permissions . push ?? false ) ,
654+ repoObj = createRepoObj ( item . full_name , item . default_branch , item . default_branch ,
655+ ( item . permissions . push ?? false ) ,
624656 null , item . private , item . fork , false ) ;
625657
626658 } else {
@@ -1535,6 +1567,22 @@ sidebarTitle.addEventListener('click', (e) => {
15351567 } else { // show learn page
15361568
15371569 sidebar . classList . add ( 'learn' ) ;
1570+
1571+ /*
1572+ // if there are no modified files
1573+ // and no pending promises
1574+ if (Object.values(modifiedFiles).length === 0
1575+ && !pendingPromise && !repoPromise) {
1576+
1577+ // enable logout
1578+ learnWrapper.classList.add('logout-enabled');
1579+
1580+ } else {
1581+
1582+ learnWrapper.classList.remove('logout-enabled');
1583+
1584+ }
1585+ */
15381586
15391587 }
15401588
@@ -1763,8 +1811,8 @@ function createNewRepoInHTML() {
17631811
17641812
17651813 // create new repo obj
1766- const repoObj = createRepoObj ( ( loggedUser + '/' + repoName ) , 'main' , true ,
1767- null , true , false , true ) ;
1814+ const repoObj = createRepoObj ( ( loggedUser + '/' + repoName ) , 'main' , 'main' ,
1815+ true , null , true , false , true ) ;
17681816
17691817 // add repo obj to modified repos
17701818 addRepoToModRepos ( repoObj ) ;
@@ -2475,7 +2523,7 @@ function setupEditor() {
24752523 } ) ;
24762524
24772525 // disable context menu
2478- if ( ! isMobile ) {
2526+ if ( ! isMobile && ! isDev ) {
24792527
24802528 window . addEventListener ( 'contextmenu' , ( e ) => {
24812529
0 commit comments