Skip to content

Commit

Permalink
Don't instantiate external access action handlers upon app launch
Browse files Browse the repository at this point in the history
Since external access typically happens either infrequently or in an
automated fashion, any small delay this instantiation creates should be
tolerable.

The reason for this change is that it allows us to run local JVM tests.
Before this change, the app could not run without a real Android device
and its Context.
  • Loading branch information
amberin committed Aug 26, 2024
1 parent c423553 commit c8bb202
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import com.orgzly.android.external.actionhandlers.*
import com.orgzly.android.external.types.Response

class ExternalAccessReceiver : BroadcastReceiver() {
val actionHandlers = listOf(
override fun onReceive(context: Context?, intent: Intent?) {
val actionHandlers = listOf(
GetOrgInfo(),
RunSearch(),
EditNotes(),
EditSavedSearches(),
ManageWidgets()
)

override fun onReceive(context: Context?, intent: Intent?) {
)
val response = actionHandlers.asSequence()
.mapNotNull { it.handle(intent!!, context!!) }
.firstOrNull()
Expand Down

0 comments on commit c8bb202

Please sign in to comment.