Add default implementation to SessionListener

This commit is contained in:
Benoit Marty
2025-10-23 16:23:01 +02:00
committed by Benoit Marty
parent 44e125dbc7
commit 66d8e6210d
8 changed files with 2 additions and 18 deletions

View File

@@ -33,7 +33,6 @@ class DefaultSeenInvitesStore(
) : SeenInvitesStore {
init {
sessionObserver.addListener(object : SessionListener {
override suspend fun onSessionCreated(userId: String) = Unit
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
if (sessionId.value == userId) {
clear()

View File

@@ -77,8 +77,6 @@ class DefaultLockScreenService(
*/
private fun observeSessionsState() {
sessionObserver.addListener(object : SessionListener {
override suspend fun onSessionCreated(userId: String) = Unit
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
// TODO handle multi session at some point
pinCodeManager.deletePinCode()

View File

@@ -35,8 +35,6 @@ class DefaultImageLoaderHolder(
private fun observeSessions() {
sessionObserver.addListener(object : SessionListener {
override suspend fun onSessionCreated(userId: String) = Unit
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
remove(SessionId(userId))
}

View File

@@ -30,7 +30,6 @@ class DefaultSessionPreferencesStoreFactory(
init {
sessionObserver.addListener(object : SessionListener {
override suspend fun onSessionCreated(userId: String) = Unit
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
val sessionPreferences = cache.remove(SessionId(userId))
sessionPreferences?.clear()

View File

@@ -108,10 +108,6 @@ class DefaultPushService(
sessionObserver.addListener(this)
}
override suspend fun onSessionCreated(userId: String) {
// Nothing to do
}
/**
* The session has been deleted.
* In this case, this is not necessary to unregister the pusher from the homeserver,

View File

@@ -59,8 +59,6 @@ class DefaultNotificationConversationService(
init {
sessionObserver.addListener(object : SessionListener {
override suspend fun onSessionCreated(userId: String) = Unit
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
onSessionLogOut(SessionId(userId))
}

View File

@@ -8,6 +8,6 @@
package io.element.android.libraries.sessionstorage.api.observer
interface SessionListener {
suspend fun onSessionCreated(userId: String)
suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean)
suspend fun onSessionCreated(userId: String) = Unit
suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) = Unit
}

View File

@@ -75,10 +75,6 @@ class DefaultAnalyticsService(
analyticsStore.setAnalyticsId(analyticsId)
}
override suspend fun onSessionCreated(userId: String) {
// Nothing to do
}
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
// Delete the store when the last session is deleted
if (sessionStore.getAllSessions().isEmpty()) {