forked from GitHub-Mirror/riotX-android
Dagger: fix no session
This commit is contained in:
parent
f91959ea96
commit
f18bc9bd00
@ -15,8 +15,13 @@
|
||||
*/
|
||||
package im.vector.matrix.android.internal.session.pushers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.work.*
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.auth.data.SessionParams
|
||||
@ -37,6 +42,7 @@ import javax.inject.Inject
|
||||
|
||||
|
||||
internal class DefaultPusherService @Inject constructor(
|
||||
private val context: Context,
|
||||
private val monarchy: Monarchy,
|
||||
private val sessionParam: SessionParams,
|
||||
private val getPusherTask: GetPushersTask,
|
||||
@ -93,7 +99,7 @@ internal class DefaultPusherService @Inject constructor(
|
||||
.setInputData(WorkerParamsFactory.toData(params))
|
||||
.setBackoffCriteria(BackoffPolicy.LINEAR, 10_000L, TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
WorkManager.getInstance().enqueue(request)
|
||||
WorkManager.getInstance(context).enqueue(request)
|
||||
return request.id
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
||||
if (refreshedToken == null) {
|
||||
Timber.w("onNewToken:received null token")
|
||||
} else {
|
||||
if (PreferencesManager.areNotificationEnabledForDevice(applicationContext)) {
|
||||
if (PreferencesManager.areNotificationEnabledForDevice(applicationContext) && activeSessionHolder.hasActiveSession()) {
|
||||
pusherManager.registerPusherWithFcmKey(refreshedToken)
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class PushersManager @Inject constructor(
|
||||
}
|
||||
|
||||
fun unregisterPusher(pushKey: String, callback: MatrixCallback<Unit>) {
|
||||
val currentSession = activeSessionHolder.getActiveSession()
|
||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
currentSession.removeHttpPusher(pushKey, stringProvider.getString(R.string.pusher_app_id), callback)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user