-
Notifications
You must be signed in to change notification settings - Fork 150
feat(desktop): Add Hide/Show Desktop Icons Feature #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This feature addresses user requests for a cleaner desktop workspace while preserving icon positions and file organization. Key implementation details: - Preference stored in puter.kv for cross-session persistence - CSS-based visibility toggle using existing .item-hidden class - Real-time sync across browser tabs via WebSocket - Applied after async item loading to prevent timing issues - Full internationalization support (37 languages) Technical approach: The visibility toggle is applied inside refresh_item_container.js after items are created but before fade-in animation. This ensures DOM elements exist when the CSS class is applied. Modified files: - src/gui/src/globals.js: Add default preference - src/gui/src/helpers.js: Add toggle_desktop_icons_visibility() - src/gui/src/UI/UIDesktop.js: Add context menu item + load preference - src/gui/src/helpers/refresh_item_container.js: Apply visibility after items load - src/gui/src/i18n/translations/*.js: Add translations (37 languages)
src/gui/src/UI/UIDesktop.js
Outdated
| show_hidden_files: JSON.parse(await puter.kv.get('user_preferences.show_hidden_files')), | ||
| language: await puter.kv.get('user_preferences.language'), | ||
| clock_visible: await puter.kv.get('user_preferences.clock_visible'), | ||
| hide_desktop_icons: JSON.parse(await puter.kv.get('user_preferences.hide_desktop_icons')) ?? false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ?? false logic is redundant.
also, why do we need to JSON.parse the value coming from puter.kv.get('user_preferences.hide_desktop_icons')?
shouldn't that always give us either a Falsy or Non falsy value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Removed JSON.parse() — puter.kv.get() already returns parsed values (the backend parses JSON when retrieving from the database), so JSON.parse() was redundant.
- Removed ?? false — puter.kv.get() returns the value if the key exists, or null if it doesn't. Since null is falsy, the fallback isn't needed for boolean checks.
israx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good so far. Let's address the single comment
- Removed JSON.parse() from hide_desktop_icons and show_hidden_files
Description
Adds a context menu option to toggle visibility of all desktop icons (including Trash). The menu text dynamically switches between "Hide Desktop Icons" and "Show Desktop Icons" based on current state. Preference persists across sessions and syncs in real-time across browser tabs.
Close Features
Closes Issue #5 Add a way to hide or show all Desktop Icon #9
Workflow
Key Changes
hide_desktop_iconspreference with cloud storage persistencetoggle_desktop_icons_visibility()helper functionImplementation Details
Approach: Uses CSS
.item-hiddenclass to toggle visibility without destroying DOM elements, preserving icon positions and event handlers.Critical Fix: Visibility is applied inside
refresh_item_container.jsafter items are loaded (not before), fixing async timing issue where icons would reappear after page refresh.Scope: Desktop only - does not affect file explorer windows.
Files Modified:
src/gui/src/globals.js- Default preferencesrc/gui/src/helpers.js- Toggle functionsrc/gui/src/UI/UIDesktop.js- Context menu + preference loadingsrc/gui/src/helpers/refresh_item_container.js- Apply visibility after item loadsrc/gui/src/i18n/translations/*.js- 37 language translations