-
Notifications
You must be signed in to change notification settings - Fork 658
Wire datastore in to FirebaseLifecycleService #5420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| */ | ||
| internal class SessionLifecycleService : Service() { | ||
| internal class SessionLifecycleService( | ||
| private var datastore: SessionDatastore = SessionDatastore(Firebase.app.applicationContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Firebase.app guaranteed to exist when this is constructed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Isn't it created first?
| updateSessionStorage(null, timeMs) | ||
| } | ||
|
|
||
| private fun updateSessionStorage(sessionId: String?, timeMs: Long) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could say sessionId: String = null here instead of the manual overloading with and without sessionId.
| // Send the value from the datastore before the first foregrounding it exists | ||
| val sessionData = currentSessionFromDatastore.get() | ||
| if (sessionData != null) { | ||
| sessionData.sessionId?.let { sendSessionToClient(client, it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sessionData?.sessionId?.let will remove the if null check.
| * The callback class that will be used to receive updated session events from the | ||
| * [SessionLifecycleService]. | ||
| */ | ||
| // TODO(rothbutter) should we use the main looper or is there one available in this SDK? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for now. I'll make the firebase common ones easy to access.
| } | ||
| } | ||
| lastMsgTimeMs = msg.getWhen() | ||
| updateSessionStorage(lastMsgTimeMs) // TODO(rothbutter) don't think we need this, eh? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. If we don't, that will be much better. I am a bit worried about using a timestamp like this, because clocks can change with daylight savings and leap seconds and whatever. In the WallClock object there is elapsedRealtime which is a monotonic increasing clock so won't go backwards no matter what happens on the calendar. Otherwise an hour forward might make everything a new session.
Generated by 🚫 Danger |
Coverage Report 1Affected Products
Test Logs |
Size Report 1Affected Products
Test Logs |
No description provided.