eventNotificationToLocationDataModel method
List<LocationDataModel>
eventNotificationToLocationDataModel(
- EventNotificationModel eventData,
- List<
String> atsignList
converts eventData
to LocationDataModel
for all atsignList
Implementation
List<LocationDataModel> eventNotificationToLocationDataModel(
EventNotificationModel eventData, List<String> atsignList) {
DateTime? _from;
DateTime? _to;
late LocationSharingFor locationSharingFor;
/// calculate DateTime from and to
if (compareAtSign(eventData.atsignCreator!,
AtEventNotificationListener().currentAtSign!)) {
_from = eventData.event!.startTime;
_to = eventData.event!.endTime;
locationSharingFor = LocationSharingFor(
_from,
_to,
LocationSharingType.Event,
!(eventData.isCancelled ?? false),
eventData.isCancelled ?? false,
eventData.isSharing ?? false);
} else {
late AtContact currentGroupMember;
// ignore: avoid_function_literals_in_foreach_calls
eventData.group!.members!.forEach((groupMember) {
// sending location to other group members
if (compareAtSign(groupMember.atSign!,
AtEventNotificationListener().currentAtSign!)) {
currentGroupMember = groupMember;
}
});
_from = startTimeEnumToTimeOfDay(
currentGroupMember.tags!['shareFrom'].toString(),
eventData.event!.startTime) ??
eventData.event!.startTime;
_to = endTimeEnumToTimeOfDay(
currentGroupMember.tags!['shareTo'].toString(),
eventData.event!.endTime) ??
eventData.event!.endTime;
locationSharingFor = LocationSharingFor(
_from,
_to,
LocationSharingType.Event,
currentGroupMember.tags!['isAccepted'],
currentGroupMember.tags!['isExited'],
currentGroupMember.tags!['isSharing']);
}
// if (atsignList == null) {
// return [locationDataModel];
// }
List<LocationDataModel> locationToShareWith = [];
// ignore: avoid_function_literals_in_foreach_calls
atsignList.forEach((element) {
LocationDataModel locationDataModel = LocationDataModel(
{
trimAtsignsFromKey(eventData.key!): locationSharingFor,
},
null,
null,
DateTime.now(),
AtClientManager.getInstance().atClient.getCurrentAtSign()!,
element,
);
// locationDataModel.receiver = element;
locationToShareWith.add(locationDataModel);
});
return locationToShareWith;
}