mapUpdatedEventDataToWidget method
void
mapUpdatedEventDataToWidget(
- EventNotificationModel eventData, {
- Map? tags,
- String? tagOfAtsign,
- bool updateLatLng = false,
- bool updateOnlyCreator = false,
Updates any EventKeyLocationModel data for updated data
Implementation
void mapUpdatedEventDataToWidget(EventNotificationModel eventData,
{Map<dynamic, dynamic>? tags,
String? tagOfAtsign,
bool updateLatLng = false,
bool updateOnlyCreator = false}) {
String neweventDataKeyId;
neweventDataKeyId = eventData.key!
.split('${MixedConstants.CREATE_EVENT}-')[1]
.split('@')[0];
for (var i = 0; i < allEventNotifications.length; i++) {
if (allEventNotifications[i].key!.contains(neweventDataKeyId)) {
/// if we want to update everything
// allEventNotifications[i].eventNotificationModel = eventData;
/// For events send tags of group members if we have and update only them
if (updateOnlyCreator) {
/// So that creator doesnt update group details
eventData.group =
allEventNotifications[i].eventNotificationModel!.group;
}
if ((tags != null) && (tagOfAtsign != null)) {
allEventNotifications[i]
.eventNotificationModel!
.group!
.members!
.where((element) => element.atSign == tagOfAtsign)
.forEach((element) {
if (updateLatLng) {
element.tags!['lat'] = tags['lat'];
element.tags!['long'] = tags['long'];
} else {
element.tags = tags;
}
});
} else {
allEventNotifications[i].eventNotificationModel = eventData;
}
allEventNotifications[i].eventNotificationModel!.key =
allEventNotifications[i].key;
// LocationService().updateEventWithNewData(
// allHybridNotifications[i].eventNotificationModel);
checkLocationSharingForEventData(
allEventNotifications[i].eventNotificationModel!);
}
}
notifyListeners();
// if ((eventData.isSharing) && (eventData.isAccepted)) {
// if (eventData.atsignCreator == currentAtSign) {
// SendLocationNotification().addMember(eventData);
// }
// } else {
// SendLocationNotification().removeMember(eventData.key);
// }
}