addDataToList method
Adds new KeyLocationModel data for new received notification
Implementation
Future<KeyLocationModel> addDataToList(
LocationNotificationModel locationNotificationModel) async {
String newLocationDataKeyId;
String tempKey;
if (locationNotificationModel.key!
.contains(MixedConstants.SHARE_LOCATION)) {
newLocationDataKeyId = locationNotificationModel.key!
.split('sharelocation-')[1]
.split('@')[0];
tempKey = 'sharelocation-$newLocationDataKeyId';
} else {
newLocationDataKeyId = locationNotificationModel.key!
.split('requestlocation-')[1]
.split('@')[0];
tempKey = 'requestlocation-$newLocationDataKeyId';
}
var key = <String>[];
if (key.isEmpty) {
key = await atClientInstance!.getKeys(
regex: tempKey,
);
}
if (key.isEmpty) {
key = await atClientInstance!.getKeys(
regex: tempKey,
sharedWith: locationNotificationModel.receiver,
);
}
if (key.isEmpty) {
key = await atClientInstance!.getKeys(
regex: tempKey,
sharedBy: locationNotificationModel.key!.contains('share')
? locationNotificationModel.atsignCreator
: locationNotificationModel.receiver,
);
}
var tempHyridNotificationModel = KeyLocationModel(key: key[0]);
tempHyridNotificationModel.atKey = getAtKey(key[0]);
tempHyridNotificationModel.atValue =
await (getAtValue(tempHyridNotificationModel.atKey!));
tempHyridNotificationModel.locationNotificationModel =
locationNotificationModel;
allLocationNotifications.add(tempHyridNotificationModel);
notifyListeners();
if ((tempHyridNotificationModel.locationNotificationModel!.isSharing)) {
if (tempHyridNotificationModel.locationNotificationModel!.atsignCreator ==
currentAtSign) {
// ignore: unawaited_futures
SendLocationNotification()
.addMember(tempHyridNotificationModel.locationNotificationModel);
}
}
return tempHyridNotificationModel;
}