Skip to content

Commit c2c87bf

Browse files
committed
refactor: Replace UIWindowDownloadDirProg with UIWindowProgress
1 parent e525747 commit c2c87bf

File tree

3 files changed

+11
-79
lines changed

3 files changed

+11
-79
lines changed

src/UI/UIWindowDownloadDirProg.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/helpers.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import UIWindowSaveAccount from './UI/UIWindowSaveAccount.js';
2727
import update_username_in_gui from './helpers/update_username_in_gui.js';
2828
import update_title_based_on_uploads from './helpers/update_title_based_on_uploads.js';
2929
import content_type_to_icon from './helpers/content_type_to_icon.js';
30-
import UIWindowDownloadDirProg from './UI/UIWindowDownloadDirProg.js';
3130
import { PROCESS_RUNNING, PortalProcess, PseudoProcess } from "./definitions.js";
3231
import UIWindowProgress from './UI/UIWindowProgress.js';
3332

@@ -2965,14 +2964,14 @@ window.zipItems = async function(el_items, targetDirPath, download = true) {
29652964
let progwin, progwin_timeout;
29662965
// only show progress window if it takes longer than 500ms to download
29672966
progwin_timeout = setTimeout(async () => {
2968-
progwin = await UIWindowDownloadDirProg();
2967+
progwin = await UIWindowProgress();
29692968
}, 500);
29702969

29712970
for (const el_item of el_items) {
29722971
let targetPath = $(el_item).attr('data-path');
29732972
// if directory, zip the directory
29742973
if($(el_item).attr('data-is_dir') === '1'){
2975-
$(progwin).find('.dir-dl-status').html(`Reading <strong>${html_encode(targetPath)}</strong>`);
2974+
progwin?.set_status(i18n('reading_file', targetPath));
29762975
// Recursively read the directory
29772976
let children = await readDirectoryRecursive(targetPath);
29782977

@@ -2985,7 +2984,7 @@ window.zipItems = async function(el_items, targetDirPath, download = true) {
29852984
relativePath = path.basename(targetPath) + '/' + child.relativePath;
29862985

29872986
// update progress window
2988-
$(progwin).find('.dir-dl-status').html(`Zipping <strong>${html_encode(relativePath)}</strong>`);
2987+
progwin?.set_status(i18n('zipping_file', relativePath));
29892988

29902989
// read file content
29912990
let content = await puter.fs.read(child.path);
@@ -3034,17 +3033,18 @@ window.zipItems = async function(el_items, targetDirPath, download = true) {
30343033
// close progress window
30353034
clearTimeout(progwin_timeout);
30363035
setTimeout(() => {
3037-
$(progwin).close();
3036+
progwin?.close();
30383037
}, Math.max(0, window.copy_progress_hide_delay - (Date.now() - start_ts)));
30393038
})
30403039
.catch(function (err) {
30413040
// close progress window
30423041
clearTimeout(progwin_timeout);
30433042
setTimeout(() => {
3044-
$(progwin).close();
3043+
progwin?.close();
30453044
}, Math.max(0, window.copy_progress_hide_delay - (Date.now() - start_ts)));
30463045

30473046
// handle errors
3047+
// TODO: Display in progress dialog
30483048
console.error("Error in zipping files: ", err);
30493049
});
30503050
}
@@ -3087,7 +3087,7 @@ window.unzipItem = async function(itemPath) {
30873087
let progwin, progwin_timeout;
30883088
// only show progress window if it takes longer than 500ms to download
30893089
progwin_timeout = setTimeout(async () => {
3090-
progwin = await UIWindowDownloadDirProg();
3090+
progwin = await UIWindowProgress();
30913091
}, 500);
30923092

30933093
const zip = new JSZip();
@@ -3109,15 +3109,15 @@ window.unzipItem = async function(itemPath) {
31093109
// close progress window
31103110
clearTimeout(progwin_timeout);
31113111
setTimeout(() => {
3112-
$(progwin).close();
3112+
progwin?.close();
31133113
}, Math.max(0, window.copy_progress_hide_delay - (Date.now() - start_ts)));
31143114

31153115
}).catch(function (e) {
31163116
// UIAlert(e.message);
31173117
// close progress window
31183118
clearTimeout(progwin_timeout);
31193119
setTimeout(() => {
3120-
$(progwin).close();
3120+
progwin?.close();
31213121
}, Math.max(0, window.copy_progress_hide_delay - (Date.now() - start_ts)));
31223122
})
31233123
}

src/i18n/translations/en.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ const en = {
198198
publish_as_website: 'Publish as website',
199199
puter_description: `Puter is a privacy-first personal cloud to keep all your files, apps, and games in one
200200
secure place, accessible from anywhere at any time.`,
201+
reading_file: "Reading %strong%",
201202
recent: "Recent",
202203
recommended: "Recommended",
203204
recover_password: "Recover Password",
@@ -281,6 +282,7 @@ const en = {
281282
yes_release_it: 'Yes, Release It',
282283
you_have_been_referred_to_puter_by_a_friend: "You have been referred to Puter by a friend!",
283284
zip: "Zip",
285+
zipping_file: "Zipping %strong%",
284286

285287
// === 2FA Setup ===
286288
setup2fa_1_step_heading: 'Open your authenticator app',

0 commit comments

Comments
 (0)