Skip to content

Commit 475c46b

Browse files
committed
Handle null modules in navigation graphs
Adds checks for null modules in the navigation graph composables. If a module is not found, the navigation controller pops the back stack to prevent navigation to invalid screens.
1 parent 54b36b1 commit 475c46b

File tree

1 file changed

+11
-0
lines changed
  • app/src/main/java/com/dergoogler/mmrl/wx/ui/navigation/graphs

1 file changed

+11
-0
lines changed

app/src/main/java/com/dergoogler/mmrl/wx/ui/navigation/graphs/Modules.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.dergoogler.mmrl.ext.panicArguments
99
import com.dergoogler.mmrl.ext.panicString
1010
import com.dergoogler.mmrl.platform.PlatformManager
1111
import com.dergoogler.mmrl.platform.model.ModId.Companion.toModId
12+
import com.dergoogler.mmrl.ui.providable.LocalNavController
1213
import com.dergoogler.mmrl.wx.ui.navigation.MainScreen
1314
import com.dergoogler.mmrl.wx.ui.screens.modules.ModulesScreen
1415
import com.dergoogler.mmrl.wx.ui.screens.modules.screens.ConfigEditorScreen
@@ -42,6 +43,11 @@ fun NavGraphBuilder.modulesScreen() = navigation(
4243

4344
val module = PlatformManager.moduleManager.getModuleById(id.toModId())
4445

46+
if (module == null) {
47+
LocalNavController.current.popBackStack()
48+
return@composable
49+
}
50+
4551
ConfigEditorScreen(module)
4652
}
4753

@@ -55,6 +61,11 @@ fun NavGraphBuilder.modulesScreen() = navigation(
5561

5662
val module = PlatformManager.moduleManager.getModuleById(id.toModId())
5763

64+
if (module == null) {
65+
LocalNavController.current.popBackStack()
66+
return@composable
67+
}
68+
5869
PluginsScreen(module)
5970
}
6071
}

0 commit comments

Comments
 (0)