diff --git a/lib/cubit/autofill_cubit.dart b/lib/cubit/autofill_cubit.dart index 9d7525c..14087c9 100644 --- a/lib/cubit/autofill_cubit.dart +++ b/lib/cubit/autofill_cubit.dart @@ -1,9 +1,9 @@ import 'package:bloc/bloc.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_autofill_service/flutter_autofill_service.dart'; import 'package:kdbx/kdbx.dart'; import 'package:keevault/logging/logger.dart'; -import 'package:meta/meta.dart'; import 'package:collection/collection.dart'; import '../config/platform.dart'; @@ -48,6 +48,8 @@ class AutofillCubit extends Cubit { return; } + // saveRequested can remain true for a long time after initial save request was made. + // Once user confirms save, autofill service will clear the intent data so then will become false. if (saveRequested) { if (state is AutofillSaving || state is AutofillSaved) { // After launching with a save intent, if we then restore after the save @@ -59,8 +61,37 @@ class AutofillCubit extends Cubit { // // A first simple attempt at a solution is below // See https://github.com/kee-org/keevault2/issues/9 for next steps - final newRequest = (state as AutofillModeActive).androidMetadata.toJson() != androidMetadata!.toJson(); + final t1 = (state as AutofillModeActive).androidMetadata; //.toJson(); + final t2 = androidMetadata!; //.toJson(); + // androidMetadata. + // l.w(MapEquality().equals(t1, t2)); + + // var equality = DeepCollectionEquality((a, b) { + // // Custom equality function that ignores hashcodes + // if (a is AutofillWebDomain && b is AutofillWebDomain) { + // return a.domain == b.domain; + // } + // return DeepCollectionEquality().equals(a, b); + // }); + final e1 = setEquals(t1.webDomains, t2.webDomains); + final e2 = setEquals(t1.packageNames, t2.packageNames); + final e3 = t1.saveInfo == t2.saveInfo; + + l.w(e1); + l.w(e2); + l.w(e3); + // l.w(t1); + // l.w(t2); + // final newRequest = (state as AutofillModeActive).androidMetadata.toJson() != androidMetadata!.toJson(); + final newRequest = !(e1 && e2 && e3); + l.e('request is new? $newRequest'); + // always true. + //TODO: mapEquals sort of thing? + // if saved and unchanged, maybe reset state to available? if (!newRequest) { + if (state is AutofillSaved) { + emit(AutofillAvailable(enabled)); + } return; } } diff --git a/pubspec.lock b/pubspec.lock index f127157..40d72cf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -294,10 +294,10 @@ packages: description: path: "." ref: master - resolved-ref: b623282b8b0bfeb6f57c25be84243171a2b4c0a6 + resolved-ref: "7d4e54bc430b22a87d4a30d8fb0f70d5ac243197" url: "https://github.com/kee-org/flutter_autofill_service.git" source: git - version: "0.17.0" + version: "0.17.1" flutter_bloc: dependency: "direct main" description: