Greenstand / Greenstand/treetracker-android

Remove unnecessary Dispatchers.Main on viewModelScope.launch

Open
#1,232 4 comments 0 reactions 1 assignee Claimed by @evanofficial View on GitHub
chore good first issue not ready for dev tech-debt triage
Dominant language
Kotlin
Stars
101
Forks
116
PR merge metrics
No merged PRs in 30d

Description

## Problem

Several ViewModels specify `Dispatchers.Main` when launching coroutines on `viewModelScope`, which already defaults to `Dispatchers.Main`. This is misleading and masks the intent — it suggests the dispatcher choice was deliberate when it's actually redundant.

```kotlin
// Current (redundant):
viewModelScope.launch(Dispatchers.Main) { ... }

// Should be:
viewModelScope.launch { ... }
```

## Locations

- `app/src/main/java/org/greenstand/android/TreeTracker/capture/TreeCaptureViewModel.kt`
- `app/src/main/java/org/greenstand/android/TreeTracker/signup/SignupViewModel.kt`

## Suggested Fix

Remove the explicit `Dispatchers.Main` parameter from `viewModelScope.launch()` calls in these files. If IO work is needed, use `withContext(Dispatchers.IO)` inside the launch block instead.

## Effort
Low

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.