getActionString method

String getActionString(
  1. EventNotificationModel event,
  2. bool haveResponded
)

Implementation

String getActionString(EventNotificationModel event, bool haveResponded) {
  if (event.isCancelled!) return 'Cancelled';
  var label = 'Action required';
  var currentAtsign =
      AtEventNotificationListener().atClientInstance!.currentAtSign;

  if (event.group!.members!.isEmpty) return '';

  event.group!.members!.forEach((member) {
    if (member.atSign![0] != '@') member.atSign = '@' + member.atSign!;
    if (currentAtsign![0] != '@') currentAtsign = '@' + currentAtsign!;

    if (member.tags!['isExited'] != null &&
        member.tags!['isExited'] == true &&
        member.atSign!.toLowerCase() == currentAtsign!.toLowerCase()) {
      label = 'Request declined';
    } else if (member.tags!['isExited'] != null &&
        member.tags!['isExited'] == false &&
        member.tags!['isAccepted'] != null &&
        member.tags!['isAccepted'] == false &&
        member.atSign!.toLowerCase() == currentAtsign!.toLowerCase() &&
        haveResponded) {
      label = 'Pending request';
    }
  });

  return label;
}