@@ -38,14 +38,6 @@ define(function (require, exports, module) {
3838 return Phoenix . VFS . getDefaultProjectDir ( ) + "Newly_added_features.md" ;
3939 }
4040
41- async function _digestMessage ( message ) {
42- const msgUint8 = new TextEncoder ( ) . encode ( message ) ; // encode as (utf-8) Uint8Array
43- const hashBuffer = await crypto . subtle . digest ( 'SHA-256' , msgUint8 ) ; // hash the message
44- const hashArray = Array . from ( new Uint8Array ( hashBuffer ) ) ; // convert buffer to byte array
45- const hashHex = hashArray . map ( b => b . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' ) ; // convert bytes to hex string
46- return hashHex ;
47- }
48-
4941 async function _getUpdateMarkdownText ( ) {
5042 return new Promise ( ( resolve , reject ) => {
5143 fetch ( _getUpdateMarkdownURL ( ) )
@@ -88,11 +80,10 @@ define(function (require, exports, module) {
8880 }
8981
9082 async function _showNewUpdatesIfPresent ( ) {
91- let newMarkdownText = await _getUpdateMarkdownText ( ) ;
92- let currentMarkdownText = await _readMarkdownTextFile ( ) ;
93- const hash = await _digestMessage ( newMarkdownText ) ;
94- const lastShownHash = await _digestMessage ( currentMarkdownText ) ;
95- if ( hash !== lastShownHash ) {
83+ // codemirror documents are always \n instead of \r\n line endings. so we strip here too
84+ let newMarkdownText = ( await _getUpdateMarkdownText ( ) ) . replace ( / [ \r ] / g, '' ) ;
85+ let currentMarkdownText = ( await _readMarkdownTextFile ( ) ) . replace ( / [ \r ] / g, '' ) ;
86+ if ( newMarkdownText !== currentMarkdownText ) {
9687 let markdownFile = FileSystem . getFileForPath ( _getUpdateMarkdownLocalPath ( ) ) ;
9788 // if the user overwrites the markdown file, then the user edited content will be nuked here.
9889 FileUtils . writeText ( markdownFile , newMarkdownText , true )
@@ -107,7 +98,6 @@ define(function (require, exports, module) {
10798 exports . init = function ( ) {
10899 if ( ! Phoenix . firstBoot && ! window . testEnvironment ) {
109100 _showNewUpdatesIfPresent ( ) ;
110- return ;
111101 }
112102 } ;
113103} ) ;
0 commit comments