Skip to content

Commit 160f556

Browse files
committed
fix: new feature md always loads up in desktop win builds
1 parent 74e1024 commit 160f556

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

src/brackets.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
define(function (require, exports, module) {
3939

4040
function _removePhoenixLoadingOverlay() {
41-
if(!window.testEnvironment){
41+
if(window.splashScreenPresent){
4242
document.getElementById('phoenix-loading-splash-screen-overlay').remove();
4343
document.getElementById('safari_splash_screen').remove();
44+
window.splashScreenPresent = false;
4445
}
4546
}
4647

src/extensions/default/Phoenix/newly-added-features.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

src/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,19 @@
137137
MIXPANEL_CUSTOM_LIB_URL:"file:"===f.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";g=f.getElementsByTagName("script")[0];g.parentNode.insertBefore(e,g)}})(document,window.mixpanel||[]);
138138
</script>
139139
<script>
140-
function _removeSplashScreenIfTest() {
141-
if(testEnvironment){
140+
window.splashScreenPresent = true;
141+
142+
function _removeSplashScreenIfNeeded() {
143+
if(testEnvironment || window.__TAURI__){
144+
// tauri means local builds and, it loads up pretty fast, so splash screen
142145
document.getElementById('phoenix-loading-splash-screen-overlay').remove();
143146
document.getElementById('safari_splash_screen').remove();
147+
window.splashScreenPresent = false;
144148
}
145149
}
146150

147151
function _loadPhoenixAfterSplashScreen() {
148-
_removeSplashScreenIfTest();
152+
_removeSplashScreenIfNeeded();
149153
var loadJS = function(url, implementationCode, location, dataMainValue){
150154
//url is URL of external file, implementationCode is the code
151155
//to be called from the file, location is the location to

0 commit comments

Comments
 (0)