immich/mobile/lib/utils
Timon f0cf3311d5
feat(mobile): Allow users to set profile picture from asset viewer (#25517)
* init

* fix

* styling

* temporary workaround for 500 error

**Root cause:**
The autogenerated Dart OpenAPI client (`UsersApi.createProfileImage()`) had two issues:
1. It set `Content-Type: multipart/form-data` without a boundary, which overrode the correct header that Dart's `MultipartRequest` would set (`multipart/form-data; boundary=...`).
2. It added the file to both `mp.fields` and `mp.files`, creating a duplicate text field.

**Result:**
Multer on the server failed to parse the multipart body, so `@UploadedFile()` was `undefined` → accessing `file.path` in `UserService.createProfileImage()` threw → **500 Internal Server Error**.

**Workaround:**
Bypass the autogenerated method in `UserApiRepository.createProfileImage()` and send the multipart request directly using the same `ApiClient` (basePath + auth), ensuring:
- No manual `Content-Type` header (let `MultipartRequest` set it with boundary)
- File only in `mp.files`, not `mp.fields`
- Proper filename fallback

* Revert "temporary workaround for 500 error"

This reverts commit 8436cd402632ca7be9272a1c72fdaf0763dcefb6.

* generate route for ProfilePictureCropPage

* add route import

* simplify

* try this

* Revert "try this"

This reverts commit fcf37d2801055c49010ddb4fd271feb900ee645a.

* try patching

* Reapply "temporary workaround for 500 error"

This reverts commit faeed810c21e4c9f0839dfff1f34aa6183469e56.

* Revert "Reapply "temporary workaround for 500 error""

This reverts commit a14a0b76d14975af98ef91748576a79cef959635.

* fix upload

* Refactor image conversion logic by introducing a new utility function. Replace inline image-to-Uint8List conversion with the new utility in EditImagePage, DriftEditImagePage, and ProfilePictureCropPage.

* use toast over snack

* format

* Revert "try patching"

This reverts commit 68a616522a1eee88c4a9755a314c0017e6450c0f.

* Enhance toast notification in ProfilePictureCropPage to include success type for better user feedback.

* Revert "simplify"

This reverts commit 8e85057a40.

* format

* add tests

* refactor to use statefulwidget

* format

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
2026-02-22 06:02:33 +00:00
..
cache refactor(mobile): consolidate image requests (#25743) 2026-02-05 12:16:42 -05:00
hooks chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
action_button.utils.dart feat(mobile): Allow users to set profile picture from asset viewer (#25517) 2026-02-22 06:02:33 +00:00
album_filter.utils.dart feat(mobile): persist album sorting & layout in settings (#22133) 2025-12-01 20:51:35 -06:00
async_mutex.dart refactor(mobile): sqlite-based map view (#20665) 2025-08-06 10:05:49 -05:00
backup_progress.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
bootstrap.dart fix: image and video download complete notification shows "file_name" (#25975) 2026-02-07 02:56:14 +00:00
bytes_units.dart feat(mobile): native clients (#21459) 2026-01-24 19:34:29 +00:00
color_filter_generator.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
datetime_comparison.dart chore: bump line length to 120 (#20191) 2025-07-25 02:37:22 +00:00
datetime_helpers.dart fix: merged timeline orderby localtime (#22371) 2025-09-29 09:53:40 -05:00
debounce.dart refactor(mobile): sqlite-based map view (#20665) 2025-08-06 10:05:49 -05:00
debug_print.dart chore(mobile): add debugPrint lint rule (#21872) 2025-09-12 18:56:00 -04:00
diff.dart refactor(mobile): device asset entity to use modified time (#17064) 2025-04-03 14:42:35 -05:00
draggable_scroll_controller.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
hash.dart feature(mobile): sync assets, albums & users to local database on device (#1759) 2023-03-03 16:38:30 -06:00
http_ssl_cert_override.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
http_ssl_options.dart fix(mobile): mtls on native clients (#25802) 2026-02-05 17:42:53 +00:00
image_converter.dart feat(mobile): Allow users to set profile picture from asset viewer (#25517) 2026-02-22 06:02:33 +00:00
image_url_builder.dart fix: mobile edit handling (#25315) 2026-01-19 12:22:53 -06:00
immich_loading_overlay.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
isolate.dart fix(mobile): mtls on native clients (#25802) 2026-02-05 17:42:53 +00:00
licenses.dart feat: add license page to app bar dialog (#19971) 2025-07-16 09:36:17 -05:00
map_utils.dart fix: mobile unawaited_futures lint (#21661) 2025-10-27 09:32:52 -05:00
migration.dart fix(mobile): mtls on native clients (#25802) 2026-02-05 17:42:53 +00:00
openapi_patching.dart fix: mobile edit handling (#25315) 2026-01-19 12:22:53 -06:00
people.utils.dart fix(mobile): person birthday viewing/editing (#20731) 2025-08-06 22:13:56 +00:00
provider_utils.dart fix: invalidate album api on log out (#20756) 2025-08-07 14:19:44 +00:00
selection_handlers.dart fix: mobile unawaited_futures lint (#21661) 2025-10-27 09:32:52 -05:00
semver.dart fix(mobile): ignore patch releases for app version alerts (#23565) 2025-11-03 21:09:32 -06:00
string_helper.dart chore: remove all deprecated endpoints/properties from server and mobile app (#9724) 2024-05-24 15:37:01 +01:00
throttle.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
thumbnail_utils.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
timezone.dart fix(mobile): use correct timezone displayed in the info sheet (#24310) 2025-12-02 16:37:19 +00:00
upload_speed_calculator.dart chore: dart http foreground upload (#24883) 2026-01-15 20:10:08 -06:00
url_helper.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00
user_agent.dart fix: mobile user agent set to immich_platform_version (#18478) 2025-05-22 10:35:24 -05:00
version_compatibility.dart chore: bump dart sdk to 3.8 (#20355) 2025-07-28 14:04:03 -05:00