Fix loading flow default bot initialization#6302
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the post-login/loading flow to initialize a locale-specific set of default bots (and skip for configured test accounts), shifting initialization out of the name setup screen and into the loading stage.
Changes:
- Add
TEST_ACCOUNT_PREFIXto default secrets and use it to bypass default-bot initialization for test accounts. - Add
isSimplifiedChineseLocale()to distinguish Simplified vs Traditional Chinese locales. - Replace single “team bot” initialization with a locale-dependent list of default bot IDs, and simplify
InitializeJobto only requirebotId.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| local.defaults.properties | Adds TEST_ACCOUNT_PREFIX default value for BuildConfig/secrets usage. |
| app/src/main/java/one/mixin/android/util/LanguageUtil.kt | Introduces Simplified-Chinese locale detection helper used by bot selection. |
| app/src/main/java/one/mixin/android/ui/landing/SetupNameFragment.kt | Removes unused/empty bot initialization hook. |
| app/src/main/java/one/mixin/android/ui/landing/LoadingFragment.kt | Initializes locale-specific default bots during loading and skips for test accounts. |
| app/src/main/java/one/mixin/android/job/InitializeJob.kt | Simplifies job input and relationship request payload. |
Comments suppressed due to low confidence (1)
app/src/main/java/one/mixin/android/job/InitializeJob.kt:13
InitializeJobis a persisted Job (persist()), and its serialized fields changed (removedbotName). To avoid deserialization failures for jobs persisted by older app versions, theserialVersionUIDshould be bumped when the class' serialized shape changes.
class InitializeJob(private val botId: String) :
BaseJob(Params(PRIORITY_LOWER).groupBy(GROUP_ID).requireWebSocketConnected().persist()) {
companion object {
private var serialVersionUID: Long = 2L
private const val GROUP_ID = "InitializeJob"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| initializeBots() | ||
| activity?.finish() | ||
| } | ||
|
|
||
| private fun initializeBots() { | ||
| val phone = Session.getAccount()?.phone.orEmpty() | ||
| val testAccountPrefix = BuildConfig.TEST_ACCOUNT_PREFIX | ||
| if (testAccountPrefix.isNotBlank() && phone.startsWith(testAccountPrefix)) { | ||
| return | ||
| } | ||
|
|
||
| val bots = if (isSimplifiedChineseLocale()) DEFAULT_BOTS_ZH_CN else DEFAULT_BOTS_EN | ||
| bots.forEach { botId -> | ||
| jobManager.addJobInBackground(InitializeJob(botId)) | ||
| } | ||
| } |
There was a problem hiding this comment.
initializeBots() enqueues 6 persisted InitializeJobs every time checkAndLoad() completes. Since InitializeActivity.showLoading() can be triggered repeatedly (e.g., from MainActivity when getIsLoaded/getIsSyncSession are false or Session.shouldUpdateKey() is true), this can repeatedly re-enqueue the same relationship requests and add avoidable startup network/work. Consider guarding with a persisted flag (per-account) or checking existing relationship in local DB before enqueuing.
…it-bots # Conflicts: # app/src/main/java/one/mixin/android/job/InitializeJob.kt
58b0d45 to
12f1d4b
Compare
# Conflicts: # app/src/main/java/one/mixin/android/job/InitializeJob.kt
3b5d8c9 to
16720e6
Compare
No description provided.