location fixes (#981)
This commit is contained in:
commit
bc6cdad1d4
|
@ -162,7 +162,7 @@ class EntityService {
|
|||
final EntityKey response = await _gateway.getKey(type);
|
||||
encryptedKey = response.encryptedKey;
|
||||
header = response.header;
|
||||
_prefs.setString(_getEntityKeyPrefix(type), encryptedKey);
|
||||
await _prefs.setString(_getEntityKeyPrefix(type), encryptedKey);
|
||||
_prefs.setString(_getEntityHeaderPrefix(type), header);
|
||||
}
|
||||
final entityKey = CryptoUtil.decryptSync(
|
||||
|
@ -171,18 +171,15 @@ class EntityService {
|
|||
Sodium.base642bin(header),
|
||||
);
|
||||
return entityKey;
|
||||
} on EntityKeyNotFound catch (e) {
|
||||
_logger.info(
|
||||
"EntityKeyNotFound generating key for type $type ${e.stackTrace}");
|
||||
} on EntityKeyNotFound {
|
||||
_logger.info("EntityKeyNotFound generating key for type $type");
|
||||
final key = CryptoUtil.generateKey();
|
||||
final encryptedKeyData = CryptoUtil.encryptSync(key, _config.getKey()!);
|
||||
await _gateway.createKey(
|
||||
type,
|
||||
Sodium.bin2base64(encryptedKeyData.encryptedData!),
|
||||
Sodium.bin2base64(encryptedKeyData.nonce!),
|
||||
);
|
||||
_prefs.setString(_getEntityKeyPrefix(type), encryptedKey);
|
||||
_prefs.setString(_getEntityHeaderPrefix(type), header);
|
||||
encryptedKey = Sodium.bin2base64(encryptedKeyData.encryptedData!);
|
||||
header = Sodium.bin2base64(encryptedKeyData.nonce!);
|
||||
await _gateway.createKey(type, encryptedKey, header);
|
||||
await _prefs.setString(_getEntityKeyPrefix(type), encryptedKey);
|
||||
await _prefs.setString(_getEntityHeaderPrefix(type), header);
|
||||
return key;
|
||||
} catch (e, s) {
|
||||
_logger.severe("Failed to getOrCreateKey for type $type", e, s);
|
||||
|
|
|
@ -46,19 +46,23 @@ class LocationService {
|
|||
//Converting the unit from kilometers to degrees for a and b as that is
|
||||
//the unit on the caritesian plane
|
||||
|
||||
final a =
|
||||
(radius * _scaleFactor(centerPoint.latitude!)) / kilometersPerDegree;
|
||||
final b = radius / kilometersPerDegree;
|
||||
final locationTag = LocationTag(
|
||||
name: location,
|
||||
radius: radius,
|
||||
aSquare: a * a,
|
||||
bSquare: b * b,
|
||||
centerPoint: centerPoint,
|
||||
);
|
||||
await EntityService.instance
|
||||
.addOrUpdate(EntityType.location, json.encode(locationTag.toJson()));
|
||||
Bus.instance.fire(LocationTagUpdatedEvent(LocTagEventType.add));
|
||||
try {
|
||||
final a =
|
||||
(radius * _scaleFactor(centerPoint.latitude!)) / kilometersPerDegree;
|
||||
final b = radius / kilometersPerDegree;
|
||||
final locationTag = LocationTag(
|
||||
name: location,
|
||||
radius: radius,
|
||||
aSquare: a * a,
|
||||
bSquare: b * b,
|
||||
centerPoint: centerPoint,
|
||||
);
|
||||
await EntityService.instance
|
||||
.addOrUpdate(EntityType.location, json.encode(locationTag.toJson()));
|
||||
Bus.instance.fire(LocationTagUpdatedEvent(LocTagEventType.add));
|
||||
} catch (e, s) {
|
||||
_logger.severe("Failed to add location tag", e, s);
|
||||
}
|
||||
}
|
||||
|
||||
///The area bounded by the location tag becomes more elliptical with increase
|
||||
|
|
|
@ -118,6 +118,7 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
|
|||
popNavAfterSubmission: false,
|
||||
shouldUnfocusOnClearOrSubmit: true,
|
||||
alwaysShowSuccessState: true,
|
||||
textCapitalization: TextCapitalization.words,
|
||||
textEditingController: _textEditingController,
|
||||
isEmptyNotifier: _isEmptyNotifier,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue