Page MenuHomePhabricator

Remove allowMainThreadQueries from AppDatabase and add suspend to DAO functions
Closed, ResolvedPublic1 Estimated Story Points

Description

We have set allowMainThreadQueries() when creating the AppDatabase instance, which is not a good practice in Room.

https://github.com/wikimedia/apps-android-wikipedia/blob/cf2ca7fa72281123fae5acfadbb73d541d3e024d/app/src/main/java/org/wikipedia/database/AppDatabase.kt#L357

This ticket is to:

  1. Remove allowMainThreadQueries from the AppDatabase.
  2. Update DAO functions with a proper suspend, which means we will need to wrap the functions with either another suspend function or a coroutine block.

Note for QA
This ticket does not change any database-related behaviors in the app, and since it is mostly related to the reading list behaviors, please make sure to run tests through reading list functions such as add, rename, move and delete reading lists/articles .

Event Timeline

Seddon set the point value for this task to 1.Jul 1 2025, 4:17 PM
Aklapper changed the subtype of this task from "Deadline" to "Task".Aug 25 2025, 8:06 AM
ABorbaWMF subscribed.

Appears to be working on 2.7.50545-alpha-2025-08-18

Tested on Pixel 6 on Android 15 and OnePlus 8 on Android 13. Tested on reading lists including add, move, delete, etc