@@ -1792,10 +1792,15 @@ function createNewFileInHTML() {
17921792 } ) ;
17931793
17941794 fileEl . querySelector ( '.name' ) . textContent = fileName ;
1795-
1796-
1795+
1796+
1797+ // generate temporary SHA
1798+ const tempSHA = generateSHA ( ) ;
1799+ setAttr ( fileEl , 'sha' , tempSHA ) ;
1800+
1801+
17971802 // change selected file
1798- changeSelectedFile ( treeLoc . join ( ) , fileContent , fileName , encodeUnicode ( '\r\n' ) , getFileLang ( fileName ) ,
1803+ changeSelectedFile ( treeLoc . join ( ) , tempSHA , fileName , encodeUnicode ( '\r\n' ) , getFileLang ( fileName ) ,
17991804 [ 0 , 0 ] , [ 0 , 0 ] , true ) ;
18001805
18011806
@@ -1872,27 +1877,28 @@ function createNewFileInHTML() {
18721877 message : commitMessage ,
18731878 file : commitFile
18741879 } ;
1880+
18751881
18761882 // push file asynchronously
1877- const newSha = await git . push ( commit ) ;
1883+ const newSHA = await git . push ( commit ) ;
18781884
18791885
1880- // update file sha in HTML with new sha from Git
1881- setAttr ( fileEl , 'sha' , newSha ) ;
1886+ // update file sha in HTML with new sha from git
1887+ setAttr ( fileEl , 'sha' , newSHA ) ;
18821888
18831889 // change selected file
1884- changeSelectedFile ( treeLoc . join ( ) , newSha , fileName , encodeUnicode ( '\r\n' ) , getFileLang ( fileName ) ,
1890+ changeSelectedFile ( treeLoc . join ( ) , newSHA , fileName , encodeUnicode ( '\r\n' ) , getFileLang ( fileName ) ,
18851891 [ 0 , 0 ] , [ 0 , 0 ] , true ) ;
1886-
1892+
18871893 // Git file is eclipsed (not updated) in browser private cache,
18881894 // so store the updated file in modifiedFiles object for 1 minute after commit
1889- if ( modifiedFiles [ fileContent ] ) {
1895+ if ( modifiedFiles [ tempSHA ] ) {
18901896
1891- onFileEclipsedInCache ( fileContent , newSha , selectedFile ) ;
1897+ onFileEclipsedInCache ( tempSHA , newSHA , selectedFile ) ;
18921898
18931899 } else {
18941900
1895- onFileEclipsedInCache ( false , newSha , selectedFile ) ;
1901+ onFileEclipsedInCache ( false , newSHA , selectedFile ) ;
18961902
18971903 }
18981904
0 commit comments