mirror of https://github.com/immich-app/immich.git
fix: android skip posting hash response after detached from engine (#23192)
fix: native cancellations for hashing Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>pull/22919/head
parent
0a6b2ad26e
commit
221e0ef02f
@ -0,0 +1,29 @@
|
||||
package app.alextran.immich.core
|
||||
|
||||
import androidx.annotation.CallSuper
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
|
||||
abstract class ImmichPlugin : FlutterPlugin {
|
||||
private var detached: Boolean = false;
|
||||
|
||||
@CallSuper
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
detached = false;
|
||||
}
|
||||
|
||||
fun detachFromEngine() {
|
||||
detached = true
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
detachFromEngine()
|
||||
}
|
||||
|
||||
fun <T> completeWhenActive(callback: (T) -> Unit, value: T) {
|
||||
if (detached) {
|
||||
return;
|
||||
}
|
||||
callback(value);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue