File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,14 +5,17 @@ import dagger.Module
55import dagger.Provides
66import dagger.hilt.InstallIn
77import dagger.hilt.components.SingletonComponent
8+ import kotlinx.coroutines.CoroutineScope
9+ import to.bitkit.ui.shared.toast.ToastQueue
810import javax.inject.Singleton
911
1012@Module
1113@InstallIn(SingletonComponent ::class )
1214object ViewModelModule {
1315 @Singleton
1416 @Provides
15- fun provideFirebaseMessaging (): FirebaseMessaging {
16- return FirebaseMessaging .getInstance()
17- }
17+ fun provideFirebaseMessaging (): FirebaseMessaging = FirebaseMessaging .getInstance()
18+
19+ @Provides
20+ fun provideToastQueueProvider (): (CoroutineScope ) -> ToastQueue = { ToastQueue (it) }
1821}
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ class AppViewModel @Inject constructor(
127127 connectivityRepo : ConnectivityRepo ,
128128 healthRepo : HealthRepo ,
129129 timedSheetManagerProvider : @JvmSuppressWildcards (CoroutineScope ) -> TimedSheetManager ,
130+ toastQueueProvider : @JvmSuppressWildcards (CoroutineScope ) -> ToastQueue ,
130131 private val toaster : Toaster ,
131132 @ApplicationContext private val context : Context ,
132133 @BgDispatcher private val bgDispatcher : CoroutineDispatcher ,
@@ -1780,7 +1781,7 @@ class AppViewModel @Inject constructor(
17801781 // endregion
17811782
17821783 // region Toasts
1783- private val toastQueue = ToastQueue (viewModelScope)
1784+ private val toastQueue = toastQueueProvider (viewModelScope)
17841785 val currentToast: StateFlow <Toast ?> = toastQueue.currentToast
17851786
17861787 fun hideToast () = toastQueue.dismissCurrentToast()
You can’t perform that action at this time.
0 commit comments