@@ -25,8 +25,12 @@ define(function (require, exports, module) {
2525 DocumentManager = require ( "document/DocumentManager" ) ,
2626 FileSystem = require ( "filesystem/FileSystem" ) ,
2727 FileUtils = require ( "file/FileUtils" ) ,
28+ StringUtils = require ( "utils/StringUtils" ) ,
29+ StateManager = require ( "preferences/StateManager" ) ,
2830 Metrics = require ( "utils/Metrics" ) ;
2931
32+ const STATE_LAST_SHOWN_HASH = "newlyAddedFeaturesHash" ;
33+
3034 function _getUpdateMarkdownURL ( ) {
3135 return Phoenix . baseURL + "assets/default-project/en/Newly_added_features.md" ;
3236 }
@@ -66,8 +70,14 @@ define(function (require, exports, module) {
6670 async function _showNewUpdatesIfPresent ( ) {
6771 // codemirror documents are always \n instead of \r\n line endings. so we strip here too
6872 let newMarkdownText = ( await _getUpdateMarkdownText ( ) ) . replace ( / \r / g, '' ) ;
73+ let newMarkdownTextHash = StringUtils . hashCode ( newMarkdownText ) ;
74+ if ( StateManager . get ( STATE_LAST_SHOWN_HASH ) === newMarkdownTextHash ) {
75+ // already shown this update, so no need to show it again.
76+ return ;
77+ }
6978 let currentMarkdownText = ( await _readMarkdownTextFile ( ) ) . replace ( / \r / g, '' ) ;
7079 if ( newMarkdownText !== currentMarkdownText ) {
80+ StateManager . set ( STATE_LAST_SHOWN_HASH , newMarkdownTextHash ) ;
7181 let markdownFile = FileSystem . getFileForPath ( _getUpdateMarkdownLocalPath ( ) ) ;
7282 // if the user overwrites the markdown file, then the user edited content will be nuked here.
7383 FileUtils . writeText ( markdownFile , newMarkdownText , true )
@@ -80,7 +90,8 @@ define(function (require, exports, module) {
8090
8191 exports . init = function ( ) {
8292 if ( ! Phoenix . firstBoot && ! window . testEnvironment ) {
83- _showNewUpdatesIfPresent ( ) ;
93+ _showNewUpdatesIfPresent ( )
94+ . catch ( console . error ) ; // fine if we dont show it once. happens mostly when offline.
8495 }
8596 } ;
8697} ) ;
0 commit comments