diff --git a/app/src/main/java/com/example/findissues/ui/issues/IssuesFragment.kt b/app/src/main/java/com/example/findissues/ui/issues/IssuesFragment.kt index 3fc0f4e..f4321b0 100644 --- a/app/src/main/java/com/example/findissues/ui/issues/IssuesFragment.kt +++ b/app/src/main/java/com/example/findissues/ui/issues/IssuesFragment.kt @@ -25,7 +25,7 @@ class IssuesFragment : Fragment() { private lateinit var viewModel: IssuesViewModel private var listState by mutableStateOf(emptyList()) var isLoading by mutableStateOf(false) - + private var storedTag = "" override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { @@ -39,11 +39,17 @@ class IssuesFragment : Fragment() { } } + override fun onPause() { + storedTag = viewModel.tag + super.onPause() + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) viewModel.getIssueLink() viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.tagSelected(storedTag) viewModel.observeIssueLiveData().collect { when (it) { is IssuesUiState.Loading -> { diff --git a/app/src/main/java/com/example/findissues/ui/issues/IssuesViewModel.kt b/app/src/main/java/com/example/findissues/ui/issues/IssuesViewModel.kt index 2a350f5..0064d5e 100644 --- a/app/src/main/java/com/example/findissues/ui/issues/IssuesViewModel.kt +++ b/app/src/main/java/com/example/findissues/ui/issues/IssuesViewModel.kt @@ -16,7 +16,8 @@ class IssuesViewModel @Inject constructor( private val repository: DataRepository ) : ViewModel() { private var issueLiveData = MutableStateFlow(IssuesUiState.Loading) - private val tags = listOf("Kotlin", "Java", "Python","Rust","React.js","Go","Javascript","Node.js") + private val tags = + listOf("Kotlin", "Java", "Python", "Rust", "React.js", "Go", "Javascript", "Node.js") var tag = "" private set