Commit ec6b3ca6 authored by Tiago Cunha's avatar Tiago Cunha

Clean up read notifications

parent ec29bb97
......@@ -10,6 +10,7 @@ import chat.rocket.android.RocketChatCache;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.ddp.RoomSubscription;
import chat.rocket.android.push.PushConstants;
import chat.rocket.android.push.PushNotificationHandler;
import chat.rocket.android.realm_helper.RealmListObserver;
import chat.rocket.android.realm_helper.RealmStore;
import chat.rocket.android.service.RocketChatService;
......@@ -64,6 +65,11 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
editor.putString(RocketChatCache.KEY_SELECTED_ROOM_ID,
intent.getStringExtra(PushConstants.ROOM_ID));
}
if (intent.hasExtra(PushConstants.NOT_ID)) {
PushNotificationHandler
.cleanUpNotificationStack(intent.getIntExtra(PushConstants.NOT_ID, 0));
}
editor.apply();
}
}
......
......@@ -42,7 +42,11 @@ public class PushNotificationHandler implements PushConstants {
private Random random = new Random();
public void setNotification(int notId, String message) {
public static synchronized void cleanUpNotificationStack(int notId) {
messageMap.remove(notId);
}
private synchronized void setNotification(int notId, String message) {
ArrayList<String> messageList = messageMap.get(notId);
if (messageList == null) {
messageList = new ArrayList<>();
......@@ -56,6 +60,10 @@ public class PushNotificationHandler implements PushConstants {
}
}
private synchronized ArrayList<String> getMessageList(int notId) {
return messageMap.get(notId);
}
public void showNotificationIfPossible(Context context, PushInteractor pushInteractor,
Bundle extras) {
......@@ -369,7 +377,7 @@ public class PushNotificationHandler implements PushConstants {
mBuilder.setContentText(fromHtml(message));
ArrayList<String> messageList = messageMap.get(notId);
ArrayList<String> messageList = getMessageList(notId);
Integer sizeList = messageList.size();
if (sizeList > 1) {
String sizeListMessage = sizeList.toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment