loadnoifications method

Future<void> loadnoifications({
  1. bool refresh = false,
})

Implementation

Future<void> loadnoifications({bool refresh = false}) async {
  if (notificationProccess.value || notificationEndProccess.value) {
    return;
  }
  notificationProccess.value = true;

  NotificationListResponse response =
      await service.notificationServices.getnotifications(
    kategori: category,
    kategoridetay: categorydetail,
    page: page.value,
  );

  if (!response.result.status) {
    log(response.result.description);
    notificationProccess.value = false;

    return;
  }

  if (response.response!.isEmpty) {
    notificationProccess.value = false;

    return;
  }

  if (page.value == 1) {
    notificationsList.value = [];
  }

  notificationsList.value ??= [];

  for (APINotificationList element in response.response!) {
    bool notificationButtons = false;

    if (element.bildirimAmac.toString() == "arkadaslik") {
      if (element.bildirimKategori.toString() == "istek") {
        notificationButtons = true;
      }
    } else if (element.bildirimAmac.toString() == "gruplar") {
      if (element.bildirimKategori.toString() == "davet") {
        notificationButtons = true;
      }
    }

    notificationsList.value!.add(
      Notifications(
        user: User(
          userID: element.bildirimGonderenID,
          displayName: Rx<String>(element.bildirimGonderenAdSoyad),
          userName: Rx<String>(element.bildirimGonderenLink.split("/").last),
          avatar: Media(
            mediaID: element.bildirimGonderenID,
            mediaType: MediaType.image,
            mediaURL: MediaURL(
              bigURL: Rx<String>(element.bildirimGonderenAvatar),
              normalURL: Rx<String>(element.bildirimGonderenAvatar),
              minURL: Rx<String>(element.bildirimGonderenAvatar),
            ),
          ),
        ),
        category: element.bildirimAmac,
        categorydetail: element.bildirimKategori,
        categorydetailID: element.bildirimKategoriDetay,
        date: element.bildirimZaman,
        enableButtons: notificationButtons,
        text: element.bildirimIcerik,
      ),
    );
  }
  updateNotificationList();

  if (response.response!.length < 20) {
    notificationEndProccess.value = true;
  }
  notificationProccess.value = false;
  page.value++;
}