mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Ensure media store scan is triggered after saving an image (fixes #6808)
This commit is contained in:
		| @@ -24,7 +24,7 @@ class ImageSaver( | ||||
| ) { | ||||
|  | ||||
|     @SuppressLint("InlinedApi") | ||||
|     suspend fun save(image: Image): Uri { | ||||
|     fun save(image: Image): Uri { | ||||
|         val data = image.data | ||||
|  | ||||
|         val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image") | ||||
| @@ -63,6 +63,8 @@ class ImageSaver( | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         DiskUtil.scanMedia(context, picture) | ||||
|  | ||||
|         return picture | ||||
|     } | ||||
|  | ||||
| @@ -77,6 +79,8 @@ class ImageSaver( | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         DiskUtil.scanMedia(context, destFile) | ||||
|  | ||||
|         return destFile.getUriCompat(context) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -343,7 +343,7 @@ class MangaPresenter( | ||||
|      * @param image the image with specified location | ||||
|      * @return flow Flow which emits the Uri which specifies where the image is saved when | ||||
|      */ | ||||
|     suspend fun saveImage(image: Image): Uri { | ||||
|     fun saveImage(image: Image): Uri { | ||||
|         return imageSaver.save(image) | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -597,7 +597,6 @@ class ReaderPresenter( | ||||
|         val relativePath = if (preferences.folderPerManga()) DiskUtil.buildValidFilename(manga.title) else "" | ||||
|  | ||||
|         // Copy file in background. | ||||
|  | ||||
|         try { | ||||
|             presenterScope.launchIO { | ||||
|                 val uri = imageSaver.save( | ||||
| @@ -608,7 +607,6 @@ class ReaderPresenter( | ||||
|                     ) | ||||
|                 ) | ||||
|                 launchUI { | ||||
|                     DiskUtil.scanMedia(context, uri) | ||||
|                     notifier.onComplete(uri) | ||||
|                     view!!.onSaveImageResult(SaveImageResult.Success(uri)) | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user