mintrocket / MintPermissions

Just use Kotlin Coroutines for Android Runtime Permissions
MIT License
68 stars 3 forks source link

UiRequestViewModel is ends silently #36

Open freelanzer1 opened 3 weeks ago

freelanzer1 commented 3 weeks ago

When the ActivityViewModel is used in the project and it is necessary to perform cleanup using requireActivity().getViewModelStore().clear (), so the UiRequestViewModel terminates silently. Since this ViewModel is created from the library, users are not always aware of its existence, but the entire logic of the library is tied to it. As a result, it is not an obvious and silent bug, which leads to the refusal to all work in the library. The proposed solution is to finalize the library in terms of outputting a message to the log that the UiRequestViewModel has ended (logging to onCleared()) or indicating that after getViewModelStore().clear() it is necessary to recreate the Activity

freelanzer1 commented 3 weeks ago

Or maybe there is another solution?

RadiationX commented 3 weeks ago

Thanks for reporting the bug. I'll think about how to fix it.

RadiationX commented 3 weeks ago

@freelanzer1 I think that you can create UiRequestViewModel on new permission requests. And after clearing ViewModelStore recreate UiRequestViewModel.

Looks like a solution to the problem, what do you think, is this solution suitable?

freelanzer1 commented 5 days ago

@RadiationX It sounds good, but if it will be done automatically, inside the library and will not require improvements from library users. Please make changes to the library or describe in the documentation how to work around this problem (with examples)

RadiationX commented 5 days ago

@freelanzer1 Fixed in version 1.1.3. https://github.com/mintrocket/MintPermissions/releases/tag/1.1.3 Nothing extra needs to be done, just update the version.

Please check if everything works correctly?