diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index 6b9d619fb6..cd110e4746 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -557,6 +557,34 @@ async function UIDesktop(options){ $(this).attr('data-path', new_el_path); }); + // Update visibility based on whether the new name starts with '.' + const old_name = path.basename(item.old_path); + const old_is_hidden = old_name.startsWith('.'); + const new_is_hidden = item.name.startsWith('.'); + + // If hidden status changed, update the visibility classes + if(old_is_hidden !== new_is_hidden){ + const all_matching_items = $(`.item[data-uid='${item.uid}']`); + + if(new_is_hidden){ + // File is now hidden + all_matching_items.removeClass('item-visible'); + if(window.user_preferences.show_hidden_files){ + all_matching_items.removeClass('item-hidden').addClass('item-revealed'); + }else{ + all_matching_items.removeClass('item-revealed').addClass('item-hidden'); + } + }else{ + // File is now visible (not hidden) + all_matching_items.removeClass('item-hidden item-revealed').addClass('item-visible'); + } + + // Update footer counts in all explorer windows + document.querySelectorAll('.window[data-app="explorer"]').forEach(el_window => { + window.update_explorer_footer_item_count(el_window); + }); + } + // Update all exact-matching windows $(`.window-${item.uid}`).each(function(){ window.update_window_path(this, new_path); diff --git a/src/gui/src/UI/UIItem.js b/src/gui/src/UI/UIItem.js index 3c2f6e294f..9c6c178830 100644 --- a/src/gui/src/UI/UIItem.js +++ b/src/gui/src/UI/UIItem.js @@ -49,7 +49,17 @@ function UIItem(options){ // set options defaults options.disabled = options.disabled ?? false; - options.visible = options.visible ?? 'visible'; // one of 'visible', 'revealed', 'hidden' + // Determine visibility based on filename if not explicitly provided + if(options.visible === undefined){ + const is_hidden_file = options.name.startsWith('.'); + if (!is_hidden_file){ + options.visible = 'visible'; + }else if (window.user_preferences.show_hidden_files) { + options.visible = 'revealed'; + }else{ + options.visible = 'hidden'; + } + } options.is_dir = options.is_dir ?? false; options.is_selected = options.is_selected ?? false; options.is_shared = options.is_shared ?? false; diff --git a/src/gui/src/UI/UIWindow.js b/src/gui/src/UI/UIWindow.js index 99bce7db0c..f255e39974 100644 --- a/src/gui/src/UI/UIWindow.js +++ b/src/gui/src/UI/UIWindow.js @@ -3327,8 +3327,24 @@ window.scale_window = (el_window)=>{ window.update_explorer_footer_item_count = function(el_window){ //update dir count in explorer footer - let item_count = $(el_window).find('.item').length; - $(el_window).find('.explorer-footer .explorer-footer-item-count').html(item_count + ` ${i18n('item')}` + (item_count == 0 || item_count > 1 ? `${i18n('plural_suffix')}` : '')); + // Count all items (excluding hidden ones) + let all_items = $(el_window).find('.item'); + let visible_items = all_items.filter(':not(.item-hidden)'); + let item_count = visible_items.length; + + // Count hidden files that are currently revealed + let hidden_items = all_items.filter('.item-revealed'); + let hidden_count = hidden_items.length; + + // Build the display text + let display_text = item_count + ` ${i18n('item')}` + (item_count == 0 || item_count > 1 ? `${i18n('plural_suffix')}` : ''); + + // Add hidden count if hidden files are shown and there are hidden files + if(window.user_preferences.show_hidden_files && hidden_count > 0){ + display_text += ` (${hidden_count} ${i18n('hidden')})`; + } + + $(el_window).find('.explorer-footer .explorer-footer-item-count').html(display_text); } window.update_explorer_footer_selected_items_count = function(el_window){ diff --git a/src/gui/src/helpers.js b/src/gui/src/helpers.js index f855fa62e6..db2114b3a5 100644 --- a/src/gui/src/helpers.js +++ b/src/gui/src/helpers.js @@ -778,6 +778,11 @@ window.show_or_hide_files = (item_containers) => { .find('.item') .filter((_, item) => item.dataset.name.startsWith('.')) .removeClass(class_to_remove).addClass(class_to_add); + + // Update footer counts in all explorer windows + document.querySelectorAll('.window[data-app="explorer"]').forEach(el_window => { + window.update_explorer_footer_item_count(el_window); + }); } window.create_folder = async(basedir, appendto_element)=>{ @@ -2352,6 +2357,33 @@ window.rename_file = async(options, new_name, old_name, old_path, el_item, el_it website_url = window.determine_website_url(new_path); $(el_item).attr('data-website_url', website_url); + // Update visibility based on whether the new name starts with '.' + const old_is_hidden = old_name.startsWith('.'); + const new_is_hidden = new_name.startsWith('.'); + + // If hidden status changed, update the visibility classes + if(old_is_hidden !== new_is_hidden){ + const all_matching_items = $(`.item[data-uid='${$(el_item).attr('data-uid')}']`); + + if(new_is_hidden){ + // File is now hidden + all_matching_items.removeClass('item-visible'); + if(window.user_preferences.show_hidden_files){ + all_matching_items.removeClass('item-hidden').addClass('item-revealed'); + }else{ + all_matching_items.removeClass('item-revealed').addClass('item-hidden'); + } + }else{ + // File is now visible (not hidden) + all_matching_items.removeClass('item-hidden item-revealed').addClass('item-visible'); + } + + // Update footer counts in all explorer windows + document.querySelectorAll('.window[data-app="explorer"]').forEach(el_window => { + window.update_explorer_footer_item_count(el_window); + }); + } + // Update all exact-matching windows $(`.window-${options.uid}`).each(function(){ window.update_window_path(this, options.path); diff --git a/src/gui/src/i18n/translations/en.js b/src/gui/src/i18n/translations/en.js index 613120afc0..320a403179 100644 --- a/src/gui/src/i18n/translations/en.js +++ b/src/gui/src/i18n/translations/en.js @@ -144,6 +144,7 @@ const en = { get_a_copy_of_on_puter: `Get a copy of '%%' on Puter.com!`, get_copy_link: 'Get Copy Link', hide_all_windows: "Hide All Windows", + hidden: 'hidden', home: 'Home', html_document: 'HTML document', hue: 'Hue',