Updates notification push max_id

This commit is contained in:
tom79 2017-09-16 09:56:26 +02:00
parent cea0531a05
commit f2de55dd0c
2 changed files with 21 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import fr.gouv.etalab.mastodon.activities.MainActivity; import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse; import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter; import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.helper.Helper;
@ -219,6 +220,15 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
public void scrollToTop(){ public void scrollToTop(){
if( lv_notifications != null) if( lv_notifications != null)
lv_notifications.setAdapter(notificationsListAdapter); lv_notifications.setAdapter(notificationsListAdapter);
//Store last toot id for home timeline to avoid to notify for those that have been already seen
//Store last notification id to avoid to notify for those that have been already seen
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
if (notifications != null && notifications.size() > 0) {
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
editor.apply();
lastReadNotifications = notifications.get(0).getId();
}
} }

View File

@ -338,8 +338,18 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
} }
public void scrollToTop(){ public void scrollToTop(){
if( lv_status != null) if( lv_status != null) {
lv_status.setAdapter(statusListAdapter); lv_status.setAdapter(statusListAdapter);
//Store last toot id for home timeline to avoid to notify for those that have been already seen
if (type == RetrieveFeedsAsyncTask.Type.HOME && statuses != null && statuses.size() > 0) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statuses.get(0).getId());
lastReadStatus = statuses.get(0).getId();
editor.apply();
}
}
} }
@Override @Override