Refresh the notifications list when it's opened

This commit is contained in:
Grishka 2023-06-25 01:28:08 +03:00
parent 0952d97557
commit a35c14865f
1 changed files with 13 additions and 2 deletions

View File

@ -51,6 +51,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
private View endMark;
private String unreadMarker, realUnreadMarker;
private MenuItem markAllReadItem;
private boolean reloadingFromCache;
@Override
public void onCreate(Bundle savedInstanceState){
@ -110,10 +111,11 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
@Override
protected void doLoadData(int offset, int count){
endMark.setVisibility(View.GONE);
if(!refreshing && !reloadingFromCache)
endMark.setVisibility(View.GONE);
AccountSessionManager.getInstance()
.getAccount(accountID).getCacheController()
.getNotifications(offset>0 ? maxID : null, count, onlyMentions, refreshing, new SimpleCallback<>(this){
.getNotifications(offset>0 ? maxID : null, count, onlyMentions, refreshing && !reloadingFromCache, new SimpleCallback<>(this){
@Override
public void onSuccess(PaginatedResponse<List<Notification>> result){
if(getActivity()==null)
@ -121,6 +123,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
onDataLoaded(result.items.stream().filter(n->n.type!=null).collect(Collectors.toList()), !result.items.isEmpty());
maxID=result.maxID;
endMark.setVisibility(result.items.isEmpty() ? View.VISIBLE : View.GONE);
reloadingFromCache=false;
}
});
}
@ -129,6 +132,14 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
protected void onShown(){
super.onShown();
unreadMarker=realUnreadMarker=AccountSessionManager.get(accountID).getLastKnownNotificationsMarker();
if(!dataLoading){
if(onlyMentions){
refresh();
}else{
reloadingFromCache=true;
refresh();
}
}
}
@Override