Ensure media store scan is triggered after saving an image (fixes #6808)

This commit is contained in:
arkon 2022-04-08 15:55:12 -04:00
parent f0eb42e72d
commit 346652e508
3 changed files with 6 additions and 4 deletions

View file

@ -24,7 +24,7 @@ class ImageSaver(
) { ) {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
suspend fun save(image: Image): Uri { fun save(image: Image): Uri {
val data = image.data val data = image.data
val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image") val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image")
@ -63,6 +63,8 @@ class ImageSaver(
} }
} }
DiskUtil.scanMedia(context, picture)
return picture return picture
} }
@ -77,6 +79,8 @@ class ImageSaver(
} }
} }
DiskUtil.scanMedia(context, destFile)
return destFile.getUriCompat(context) return destFile.getUriCompat(context)
} }
} }

View file

@ -343,7 +343,7 @@ class MangaPresenter(
* @param image the image with specified location * @param image the image with specified location
* @return flow Flow which emits the Uri which specifies where the image is saved when * @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) return imageSaver.save(image)
} }

View file

@ -597,7 +597,6 @@ class ReaderPresenter(
val relativePath = if (preferences.folderPerManga()) DiskUtil.buildValidFilename(manga.title) else "" val relativePath = if (preferences.folderPerManga()) DiskUtil.buildValidFilename(manga.title) else ""
// Copy file in background. // Copy file in background.
try { try {
presenterScope.launchIO { presenterScope.launchIO {
val uri = imageSaver.save( val uri = imageSaver.save(
@ -608,7 +607,6 @@ class ReaderPresenter(
) )
) )
launchUI { launchUI {
DiskUtil.scanMedia(context, uri)
notifier.onComplete(uri) notifier.onComplete(uri)
view!!.onSaveImageResult(SaveImageResult.Success(uri)) view!!.onSaveImageResult(SaveImageResult.Success(uri))
} }