Fix mark all notifications as read

This commit is contained in:
M M Arif
2022-07-09 14:24:18 +05:00
parent 39f961e746
commit e1f5f272cf

View File

@@ -32,12 +32,12 @@ import org.mian.gitnex.helpers.contexts.IssueContext;
import org.mian.gitnex.helpers.contexts.RepositoryContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* Author opyale
* Modified M M Arif
* @author opyale
* @author M M Arif
*/
public class NotificationsFragment extends Fragment implements NotificationsAdapter.OnNotificationClickedListener, NotificationsAdapter.OnMoreClickedListener {
@@ -111,7 +111,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
viewBinding.markAllAsRead.setOnClickListener(v1 ->
RetrofitClient.getApiInterface(context)
.notifyReadList(new Date(), "true", Arrays.asList("unread", "pinned"), "read")
.notifyReadList(null, "false", Arrays.asList("unread", "pinned"), "read")
.enqueue((SimpleCallback<List<NotificationThread>>) (call, voidResponse) -> {
if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
@@ -151,15 +151,15 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
notificationThreads.clear();
}
if(listResponse.get().body().size() > 0) {
notificationThreads.addAll(listResponse.get().body());
if(Objects.requireNonNull(listResponse.get().body()).size() > 0) {
notificationThreads.addAll(Objects.requireNonNull(listResponse.get().body()));
}
else {
notificationsAdapter.setMoreDataAvailable(false);
}
if(!append || listResponse.get().body().size() > 0) {
notificationsAdapter.notifyDataSetChanged();
if(!append || Objects.requireNonNull(listResponse.get().body()).size() > 0) {
notificationsAdapter.notifyDataChanged();
}
}