-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disconnect provider and ownership #7386
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
Reviewed 12 of 12 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Rawa)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 60 at r1 (raw file):
Ownership.entries } else { Ownership.entries.filter { ownership ->
I think this could be simplified and be more like this:
allProviders.filter { it.providerId in selectedProviders }
.flatMap { it.ownership }
.distinct()
Could probably improve on the flatmap as well.
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 107 at r1 (raw file):
fun onApplyButtonClicked() { val newSelectedOwnership = selectedOwnership.value.toOwnershipConstraint() // TODO should be all providers?!
Could do something like
availableProvidersUseCase.invoke().first()
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 5 of 16 files reviewed, 2 unresolved discussions (waiting on @Pururun)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 60 at r1 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
I think this could be simplified and be more like this:
allProviders.filter { it.providerId in selectedProviders } .flatMap { it.ownership } .distinct()
Could probably improve on the flatmap as well.
Fixed by reworking data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 5 of 16 files reviewed, 2 unresolved discussions (waiting on @Pururun)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 107 at r1 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
Could do something like
availableProvidersUseCase.invoke().first()
maybe?
Simplified in new version.
9aa8c89
to
0529627
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 11 files at r2, 15 of 15 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Rawa)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 107 at r1 (raw file):
Previously, Rawa (David Göransson) wrote…
Simplified in new version.
Do we actually need allProviders in the ui state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Pururun)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 107 at r1 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
Do we actually need allProviders in the ui state?
We need it to see if all providers are selected.
val isAllProvidersChecked = allProviders.size == selectedProviders.size
We could use the providersToOwnershipUseCase
here to get the full list of providers, but we would still need it in the UI state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/FilterViewModel.kt
line 107 at r1 (raw file):
Previously, Rawa (David Göransson) wrote…
We need it to see if all providers are selected.
val isAllProvidersChecked = allProviders.size == selectedProviders.size
We could use the
providersToOwnershipUseCase
here to get the full list of providers, but we would still need it in the UI state.
Right, then all good!
0529627
to
04d9fb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 12 files at r1, 3 of 11 files at r2, 15 of 15 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Rawa)
android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCaseTest.kt
line 25 at r3 (raw file):
private val mockRelayListFilterRepository: RelayListFilterRepository = mockk() private val mockProvidersOwnershipUseCase: ProviderToOwnershipsUseCase = mockk()
nit: mockProviderToOwnershipsUseCase
Code quote:
ProvidersOwnership
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 65 at r3 (raw file):
true } else { providerOwnershipRelationship[providerId]!!.contains(
Is this safe? E.g. what if a provider is used as a constraint is later removed from the relay list?
Code quote:
!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Rawa)
a discussion (no related file):
Don't forget to update the changelog!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Rawa)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 24 of 25 files reviewed, 1 unresolved discussion (waiting on @albin-mullvad)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 65 at r3 (raw file):
Previously, albin-mullvad wrote…
Is this safe? E.g. what if a provider is used as a constraint is later removed from the relay list?
Addressed. Was not safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @albin-mullvad)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Rawa)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 65 at r3 (raw file):
Previously, Rawa (David Göransson) wrote…
Addressed. Was not safe.
Nice! 👍
Can we add some unit test to somehow cover this case as well? Basically something like:
- Set a provider in the provider filter
- Change the underlying relay list
- Ensure that the provider is part of the removed relays
Might even be easier ways to achieve this 🤔
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 69 at r5 (raw file):
// so it is visible for the user. Because we won't know what // ownerships it // had
nit
Code quote:
// ownerships it
// had
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Rawa)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 24 of 25 files reviewed, all discussions resolved (waiting on @albin-mullvad and @Pururun)
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 65 at r3 (raw file):
Previously, albin-mullvad wrote…
Nice! 👍
Can we add some unit test to somehow cover this case as well? Basically something like:
- Set a provider in the provider filter
- Change the underlying relay list
- Ensure that the provider is part of the removed relays
Might even be easier ways to achieve this 🤔
I believe @Pururun fixed tests
android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/FilterChipUseCase.kt
line 69 at r5 (raw file):
Previously, albin-mullvad wrote…
nit
Addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved
cbbb316
to
99bd279
Compare
This PR changes the one-to-one relationship to one-to-many between provider and ownership.
This change is