Skip to content

Commit

Permalink
auto refresh repos on api key reset
Browse files Browse the repository at this point in the history
Signed-off-by: androidacy-user <[email protected]>
  • Loading branch information
androidacy-user committed Sep 11, 2023
1 parent b5d2d96 commit 27e0e93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
}
onMainActivityCreate(this)
super.onCreate(savedInstanceState)
INSTANCE = this
TrackHelper.track().screen(this).with(MainApplication.INSTANCE!!.tracker)
// hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
if (BuildConfig.ENABLE_PROTECTION && !MainApplication.o && !BuildConfig.DEBUG) {
Expand Down Expand Up @@ -814,6 +815,11 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
return super.dispatchTouchEvent(event)
}

override fun onDestroy() {
super.onDestroy()
INSTANCE = null
}

companion object {
fun getAppCompatActivity(activity: AppCompatActivity): AppCompatActivity {
return activity
Expand All @@ -831,5 +837,6 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
var localModuleInfoList: List<LocalModuleInfo> = ArrayList()
var onlineModuleInfoList: List<RepoModule> = ArrayList()
var isShowingWeblateSb = false // race condition
var INSTANCE: MainActivity? = null
}
}
4 changes: 4 additions & 0 deletions app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
R.string.api_key_removed,
Toast.LENGTH_SHORT
).show()
// refresh by faking user pull down
if (MainActivity.INSTANCE != null) {
MainActivity.INSTANCE!!.onRefresh()
}
}
}
builder.show()
Expand Down

0 comments on commit 27e0e93

Please sign in to comment.