Pinned messages analytics : introduce LocalAnalyticsService so we can easily inject it in views
This commit is contained in:
18
services/analytics/compose/build.gradle.kts
Normal file
18
services/analytics/compose/build.gradle.kts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2023, 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.services.analytics.compose"
|
||||
|
||||
}
|
||||
dependencies {
|
||||
api(projects.services.analytics.api)
|
||||
implementation(projects.services.analytics.noop)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.analytics.compose
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import io.element.android.services.analytics.api.AnalyticsService
|
||||
import io.element.android.services.analytics.noop.NoopAnalyticsService
|
||||
|
||||
/**
|
||||
* Global key to access the [AnalyticsService] in the composition tree.
|
||||
*/
|
||||
val LocalAnalyticsService = staticCompositionLocalOf<AnalyticsService> {
|
||||
NoopAnalyticsService()
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class, boundType = AnalyticsService::class)
|
||||
@ContributesBinding(AppScope::class, boundType = AnalyticsService::class, priority = ContributesBinding.Priority.HIGHEST)
|
||||
class DefaultAnalyticsService @Inject constructor(
|
||||
private val analyticsProviders: Set<@JvmSuppressWildcards AnalyticsProvider>,
|
||||
private val analyticsStore: AnalyticsStore,
|
||||
|
||||
Reference in New Issue
Block a user