Skip to content

Conversation

@PrayagCodes
Copy link

@PrayagCodes PrayagCodes commented Oct 20, 2025

Description

This PR adds a "Remove" button to account settings, which allows users to delete their profile picture and revert to the default avatar.

Before

image

After

image

Implementation

image

Related Issue

Closes Issue #1 - Add ability to remove profile picture #5

Changes Made

Core Functionality

  • Added remove button UI in account settings (visible only when user has a profile picture)
  • Added Confirmation Model to prompt the user and confirm the action
  • Implemented a click handler to remove the picture and update the UI in real-time
  • Modified update_profile() helper function to support field deletion
  • Button uses danger styling (button-danger class) for consistency

Internationalization

  • Added remove_profile_picture / confirm_remove_profile_picture translation key to all 38 supported languages
  • Refined translations for proper verb forms and grammar in 10 languages

Implementation Details

  • Profile deletion: passes {picture: null} to update_profile()
  • Deletes picture field from /{username}/Public/.profile JSON file
  • UI updates without page refresh
  • Button visibility tied to profile picture existence

Testing Performed

  • Button appears when profile picture exists
  • Clicking button removes picture and reverts to default avatar
  • Button hides after picture removal
  • Button reappears when new picture uploaded
  • Toolbar profile image updates correctly
  • Changes persist after page refresh
  • All 38 language translations verified

Files Modified

  • src/gui/src/helpers.js - Profile deletion logic
  • src/gui/src/UI/Settings/UITabAccount.js - UI components and event handlers
  • src/gui/src/i18n/translations/*.js - All 38 translation files

PrayagCodes and others added 3 commits October 18, 2025 15:31
- Add 'Remove' button to account settings UI below profile picture
- Button only appears when user has an uploaded profile picture
- Clicking button removes picture and reverts to default avatar
- Update update_profile() helper to handle profile field deletion
- Style button with button-danger class for consistent UI

Changes:
* UITabAccount.js: Add remove button UI, click handler, and show/hide logic
* helpers.js: Update update_profile() to delete fields when value is null

The button is styled as a danger action (red background, white text)
and disappears after removing the picture or when no picture exists.
- Add translations for all 38 supported languages
- Add UIAlert confirmation dialog when user attempts to remove profile picture
- Implement flag to prevent multiple simultaneous removal operations
- Add backdrop overlay to block interactions during confirmation
- Change remove button style from 'primary' to 'danger' for better UX
- Add 'confirm_remove_profile_picture' translation key to all 37 language files

Changes:
- src/gui/src/UI/Settings/UITabAccount.js:
  * Import UIAlert component
  * Add is_removing_profile_picture flag to prevent race conditions
  * Wrap removal logic in try-finally block for proper cleanup
  * Add confirmation dialog with backdrop and danger-styled button

- src/gui/src/i18n/translations/*.js:
  * Add confirmation message in 37 languages
  * Message: 'Are you sure you want to remove your profile picture?'
@PrayagCodes PrayagCodes marked this pull request as ready for review October 20, 2025 05:30
profile[key] = key_vals[key];
// update window.user.profile
window.user.profile[key] = key_vals[key];
if (key_vals[key] === null || key_vals[key] === undefined || key_vals[key] === '') {
Copy link

@israx israx Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: null , undefined and '' are falsy values, which means we can substitute code above by

Suggested change
if (key_vals[key] === null || key_vals[key] === undefined || key_vals[key] === '') {
if (!!key_vals[key]) {

h += `<div class="profile-picture change-profile-picture" style="background-image: url('${html_encode(window.user?.profile?.picture ?? window.icons['profile.svg'])}');">`;
h += `</div>`;
h += `</div>`;
h += `<div style="text-align: center; margin-bottom: 20px;">`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Let's make sure we are being consistent with styles here. We should establish a boundary when to use inline-styles vs css.

inline-styles can be beneficial for referring to javascript code such as the profile picture online 39.


$el_window.find('.remove-profile-picture').on('click', async function (e) {
// Prevent multiple simultaneous operations
if(is_removing_profile_picture)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Ideally, instead of deduping this call, we should disable the remove profile picture button while the picture is being deleted

Copy link

@israx israx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Great job Prayag. PR description is pretty descriptive. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue #1 - Add ability to remove profile picture

2 participants