Skip to content

Commit b444717

Browse files
authored
Merge pull request #2323 from ethereum/yann300-patch-41
fix load with remix desktop
2 parents 6dcc7ae + 3bdc23e commit b444717

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

apps/remix-ide/src/assets/js/loader.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,28 @@ createScriptTag = function (url, type) {
2525
script.type = type;
2626
document.getElementsByTagName('head')[0].appendChild(script);
2727
};
28-
fetch('assets/version.json', { cache: "no-store" }).then(response => {
28+
29+
function isElectron() {
30+
// Renderer process
31+
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
32+
return true
33+
}
34+
35+
// Main process
36+
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
37+
return true
38+
}
39+
40+
// Detect the user agent when the `nodeIntegration` option is set to false
41+
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
42+
return true
43+
}
44+
45+
return false
46+
}
47+
48+
const versionUrl = isElectron() ? 'https://remix.ethereum.org/assets/version.json' : 'assets/version.json'
49+
fetch(versionUrl, { cache: "no-store" }).then(response => {
2950
response.text().then(function (data) {
3051
const version = JSON.parse(data);
3152
console.log(`Loading Remix ${version.version}`);

0 commit comments

Comments
 (0)