Skip to content
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

Fix Login Bug #950

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/java/com/hover/stax/ApplicationInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import com.appsflyer.AppsFlyerProperties
import com.google.firebase.FirebaseApp
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.hover.sdk.api.Hover
import com.hover.stax.storage.user.di.DatabaseModule
import com.hover.stax.di.appModule
import com.hover.stax.di.dataModule
import com.hover.stax.di.datastoreModule
import com.hover.stax.di.ktorModule
import com.hover.stax.di.repositories
import com.hover.stax.di.useCases
import com.hover.stax.storage.user.di.storage
import com.hover.stax.utils.network.NetworkMonitor
import com.jakewharton.processphoenix.ProcessPhoenix
import com.yariksoffice.lingver.Lingver
Expand Down Expand Up @@ -69,7 +69,7 @@ class ApplicationInstance : Application() {
private fun initDI() {
startKoin {
androidContext(this@ApplicationInstance)
modules(appModule + dataModule + ktorModule + datastoreModule + useCases + repositories + com.hover.stax.storage.user.di.DatabaseModule.repository)
modules(appModule + dataModule + ktorModule + datastoreModule + useCases + repositories + storage)
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/hover/stax/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ val appModule = module {
viewModelOf(::SimViewModel)
}

val dataModule = module(createdAtStart = true) {
single { AppDatabase.getInstance(get()) }
single { HoverRoomDatabase.getInstance(get()) }
val dataModule = module {
single { AppDatabase.getInstance(androidApplication()) }
single { HoverRoomDatabase.getInstance(androidApplication()) }
single { get<AppDatabase>().userDao() }

singleOf(::TransactionRepo)
Expand Down Expand Up @@ -195,5 +195,5 @@ val useCases = module {

factoryOf(::GetChannelBountiesUseCase)

factoryOf(::StaxUserUseCase)
singleOf(::StaxUserUseCase)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module

object DatabaseModule {

val repository = module {
singleOf(::StaxUserRepositoryImpl) { bind<StaxUserRepository>() }
}
val storage = module {
singleOf(::StaxUserRepositoryImpl) { bind<StaxUserRepository>() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ internal class StaxUserRepositoryImpl(
) : StaxUserRepository {
override fun getUserAsync(): Flow<StaxUser> = userDao.getUserAsync()

override suspend fun saveUser(user: StaxUser) {
userDao.getUser()?.let {
userDao.insertAsync(user)
} ?: userDao.update(user)
}
override suspend fun saveUser(user: StaxUser) = userDao.insertAsync(user)

override suspend fun deleteUser(user: StaxUser) = userDao.delete(user)
}