Skip to content

Commit d02e83e

Browse files
authored
Deffer validation (#7519)
1 parent 72908db commit d02e83e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ constructor(
6464
override var isInForeground = false
6565
private set
6666

67+
private var pendingForegroundCheck = false
68+
6769
/**
6870
* Either notify the subscribers with general multi-process supported session or fallback local
6971
* session
@@ -93,6 +95,10 @@ constructor(
9395
}
9496
.collect { sessionData ->
9597
localSessionData = sessionData
98+
if (pendingForegroundCheck) {
99+
pendingForegroundCheck = false
100+
appForeground()
101+
}
96102
val sessionId = sessionData.sessionDetails.sessionId
97103
notifySubscribers(sessionId, NotificationType.GENERAL)
98104
}
@@ -122,6 +128,7 @@ constructor(
122128
override fun appForeground() {
123129
isInForeground = true
124130
if (!::localSessionData.isInitialized) {
131+
pendingForegroundCheck = true
125132
Log.d(TAG, "App foregrounded, but local SessionData not initialized")
126133
return
127134
}

0 commit comments

Comments
 (0)