Skip to content

Commit

Permalink
fix: set fake patch file name when picking a patch from a zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
marcrobledo committed Aug 11, 2024
1 parent de2f0e5 commit 9ec7744
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion _cache_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

var PRECACHE_ID = 'rom-patcher-js';
var PRECACHE_VERSION = 'v30rc1';
var PRECACHE_VERSION = 'v30rc1b';
var PRECACHE_URLS = [
'/RomPatcher.js/', '/RomPatcher.js/index.html',
'/RomPatcher.js/manifest.json',
Expand Down
12 changes: 6 additions & 6 deletions rom-patcher-js/RomPatcher.webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ var RomPatcherWeb = (function () {
return fallback || 0;
},
setFakeFile: function (id, fileName) {
if (document.getElementById('rom-patcher-' + id)) {
if (document.getElementById('rom-patcher-input-file-' + id)) {
try {
/* add a fake file to the input file, so it shows the chosen file name */
const fakeFile = new File(new Uint8Array(0), fileName);
const dataTransfer = new DataTransfer();
dataTransfer.items.add(fakeFile);
document.getElementById('rom-patcher-' + id).files = dataTransfer.files;
document.getElementById('rom-patcher-input-file-' + id).files = dataTransfer.files;
} catch (ex) {
console.warning('File API constructor is not supported');
}
Expand Down Expand Up @@ -636,7 +636,7 @@ var RomPatcherWeb = (function () {
}

if (transferFakeFile) {
htmlElements.setFakeFile('input-file-rom', romFile.fileName);
htmlElements.setFakeFile('rom', romFile.fileName);
}
},

Expand Down Expand Up @@ -744,7 +744,7 @@ var RomPatcherWeb = (function () {
}

if (transferFakeFile) {
htmlElements.setFakeFile('input-file-patch', binFile.fileName);
htmlElements.setFakeFile('patch', binFile.fileName);
}
} else {
_setToastError(_('Invalid patch file'));
Expand All @@ -762,7 +762,7 @@ var RomPatcherWeb = (function () {

refreshRomFileName: function () {
if (romFile)
htmlElements.setFakeFile('input-file-rom', romFile.fileName);
htmlElements.setFakeFile('rom', romFile.fileName);
},

pickEmbededFile: function (fileName) {
Expand Down Expand Up @@ -1059,7 +1059,7 @@ const ZIPManager = (function (romPatcherWeb) {
onUnzip(binFile, true);
} else {
_setPatchInputSpinner(false);
onUnzip(binFile);
onUnzip(binFile, true);
}
};
fileReader.readAsArrayBuffer(blob);
Expand Down

0 comments on commit 9ec7744

Please sign in to comment.