Skip to content

Commit 9f556ae

Browse files
committed
fix(messaging, android): properly shrink stored messages to limit
previously, stored messages were cleared one at a time each time a message came in, opening the possibility that the store would contain more messages then the limit and never get back down to the limit. now it will attempt to shrink down to the limit every time a message comes in ensuring that if there is an over limit condition it will be fixed quickly
1 parent 9178ffd commit 9f556ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public void storeFirebaseMessage(RemoteMessage remoteMessage) {
3535

3636
// check and remove old notifications message
3737
List<String> allNotificationList = convertToArray(notificationIds);
38-
if (allNotificationList.size() > MAX_SIZE_NOTIFICATIONS) {
38+
while (allNotificationList.size() > MAX_SIZE_NOTIFICATIONS) {
3939
clearFirebaseMessage(allNotificationList.get(0));
40+
allNotificationList.remove(0);
4041
}
4142
} catch (JSONException e) {
4243
e.printStackTrace();

0 commit comments

Comments
 (0)