Skip to content

Commit ec3703f

Browse files
authored
fix: check current destination before navigating on MainActivity (#218)
1 parent 6d504e2 commit ec3703f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.github/workflows/pr_ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
with:
1818
submodules: 'recursive'
1919
fetch-depth: 0
20+
2021
- name: Get changed files
2122
id: changed-files
2223
uses: tj-actions/[email protected]
@@ -28,6 +29,12 @@ jobs:
2829
**/*.kts
2930
**/*.xml
3031
32+
- name: List all changed files
33+
run: |
34+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
35+
echo "$file was changed"
36+
done
37+
3138
check-codestyle:
3239
needs: [ file-changes ]
3340
runs-on: ubuntu-latest

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
<activity
2929
android:name=".MainActivity"
30-
android:configChanges="orientation|screenSize"
3130
android:exported="true"
3231
android:theme="@style/Theme.Qbit">
3332
<intent-filter>

app/src/main/kotlin/dev/yashgarg/qbit/MainActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ class MainActivity : AppCompatActivity() {
5656
when (status) {
5757
ConfigStatus.EXISTS -> {
5858
val bundle = bundleOf(TORRENT_INTENT_KEY to intent?.data.toString())
59+
val navController =
60+
findNavController(this@MainActivity, R.id.nav_host_fragment)
5961

6062
serverPrefsStore.data
6163
.map { it.showNotification }
6264
.onEach(::launchWorkManager)
6365
.launchIn(lifecycleScope)
6466

65-
findNavController(this@MainActivity, R.id.nav_host_fragment)
66-
.navigate(R.id.action_homeFragment_to_serverFragment, bundle)
67+
if (navController.currentDestination?.id == R.id.homeFragment) {
68+
navController.navigate(
69+
R.id.action_homeFragment_to_serverFragment,
70+
bundle
71+
)
72+
}
6773
}
6874
ConfigStatus.DOES_NOT_EXIST -> Log.i(ClientManager.tag, "No config found!")
6975
}

0 commit comments

Comments
 (0)