Skip to content

Commit 75f0919

Browse files
authored
Do not notify subscribers when session didn't change (#6988)
Tested manually using sessions test app. This is a trivial change
1 parent c1a8186 commit 75f0919

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SharedSessionRepository.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ constructor(
6161
}
6262

6363
internal var previousNotificationType: NotificationType = NotificationType.GENERAL
64+
private var previousSessionId: String = ""
6465

6566
init {
6667
CoroutineScope(backgroundDispatcher).launch {
@@ -171,6 +172,10 @@ constructor(
171172

172173
private suspend fun notifySubscribers(sessionId: String, type: NotificationType) {
173174
previousNotificationType = type
175+
if (previousSessionId == sessionId) {
176+
return
177+
}
178+
previousSessionId = sessionId
174179
FirebaseSessionsDependencies.getRegisteredSubscribers().values.forEach { subscriber ->
175180
// Notify subscribers, regardless of sampling and data collection state
176181
subscriber.onSessionChanged(SessionSubscriber.SessionDetails(sessionId))

0 commit comments

Comments
 (0)