Skip to content

Commit

Permalink
fix: 🐛 crash when document dir is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyBridle committed Jan 12, 2024
1 parent 1919971 commit ed7c7f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ModuleRepositoryImpl @Inject constructor(
override suspend fun getModuleDirs(): List<Uri> {

val preferences = context.filepathDatastore.data.first()
if (preferences.CHOUTEN_ROOT_DIR == Uri.EMPTY) return emptyList()
val contentResolver = context.contentResolver

return withContext(Dispatchers.IO) {
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/chouten/app/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ object AppModule {
@Provides
fun provideModuleRepository(app: Application, httpClient: Requests): ModuleRepository {
val moduleDirGetter: suspend (Uri) -> Uri = { uri: Uri ->
GetModuleDirUseCase(
app.applicationContext
)(uri)
try {
GetModuleDirUseCase(
app.applicationContext
)(uri)
} catch (e: Exception) {
Uri.EMPTY
}
}
return ModuleRepositoryImpl(app.applicationContext, moduleDirGetter)
}
Expand Down

0 comments on commit ed7c7f4

Please sign in to comment.