From a917458a0711de5781c3877bee3f16886189618a Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 11 Sep 2022 15:58:25 +0800 Subject: [PATCH] Only schedule a metadata task when saving to server --- .../nkming/nc_photos/plugin/ImageProcessorService.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/android/src/main/kotlin/com/nkming/nc_photos/plugin/ImageProcessorService.kt b/plugin/android/src/main/kotlin/com/nkming/nc_photos/plugin/ImageProcessorService.kt index 91353c13..ae249af4 100644 --- a/plugin/android/src/main/kotlin/com/nkming/nc_photos/plugin/ImageProcessorService.kt +++ b/plugin/android/src/main/kotlin/com/nkming/nc_photos/plugin/ImageProcessorService.kt @@ -340,7 +340,7 @@ class ImageProcessorService : Service() { ) cmdTask = object : ImageProcessorCommandTask(applicationContext) { override fun onPostExecute(result: MessageEvent) { - notifyResult(result) + notifyResult(result, cmd.isSaveToServer) cmds.removeFirst() stopSelf(cmd.startId) cmdTask = null @@ -386,9 +386,13 @@ class ImageProcessorService : Service() { } } - private fun notifyResult(event: MessageEvent) { + private fun notifyResult(event: MessageEvent, shouldFireEvent: Boolean) { if (event is ImageProcessorCompletedEvent) { - NativeEventChannelHandler.fire(ImageProcessorUploadSuccessEvent()) + if (shouldFireEvent) { + NativeEventChannelHandler.fire( + ImageProcessorUploadSuccessEvent() + ) + } notificationManager.notify( RESULT_NOTIFICATION_ID, buildResultNotification(event.result) )