Skip location update if file is not uploaded or owned by user

This commit is contained in:
Neeraj Gupta 2023-04-18 13:55:32 +05:30
parent ef6c84ad97
commit ef5d1ec257
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -64,7 +64,8 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
widget.file.fileType == FileType.livePhoto;
_exifNotifier.addListener(() {
if (_exifNotifier.value != null && !widget.file.hasLocation) {
if (_exifNotifier.value != null &&
!widget.file.hasLocation &&) {
_updateLocationFromExif(_exifNotifier.value!).ignore();
}
});
@ -238,6 +239,11 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
//missing and the EXIF has location data. This is only happens for a
//certain specific minority of devices.
Future<void> _updateLocationFromExif(Map<String, IfdTag> exif) async {
// If the file is not uploaded or the file is not owned by the current user
// then we don't need to update the location.
if (!widget.file.isUploaded || widget.file.ownerID! != _currentUserID) {
return;
}
try {
final locationDataFromExif = locationFromExif(exif);
if (locationDataFromExif?.latitude != null &&