Skip to content
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

feat(run-v2): link installation #90

Merged
merged 16 commits into from
Sep 10, 2024
Merged

feat(run-v2): link installation #90

merged 16 commits into from
Sep 10, 2024

Conversation

aanorbel
Copy link
Member

@aanorbel aanorbel commented Sep 6, 2024

Fixes: #52

. . .
Screenshot_20240906_175857 Screenshot_20240906_180232 Screenshot_20240906_190700

@aanorbel aanorbel requested a review from sdsantos September 6, 2024 16:56
@aanorbel aanorbel marked this pull request as ready for review September 9, 2024 08:10
Base automatically changed from run-tests-screen to main September 9, 2024 13:28
Copy link
Contributor

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only blocking change is that the deeplinks don't work if the app is not running.

android:scheme="https" />
</intent-filter>

<intent-filter android:autoVerify="true">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting a Missing required elements/attributes for Android App Links warning here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android wants the scheme below to be http/https

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe we don't need the autoVerify here? Or we can still verify the ooni scheme?

)
}
}.onFailure {
onError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also tell the Screen to display the error, and use the onBack here instead. Snackbars are tied to the Activity, so they survive if you switch screens.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onError shows an error message before going back

onEvent(AddDescriptorViewModel.Event.AutoRunChanged(!state.allTestsSelected()))
},
) {
Checkbox(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out there's a TriStateCheckbox that I used on my run tests PR.

onBack()
},
fetchDescriptor = {
withContext(backgroundDispatcher) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should hide this detail inside the fetchDescriptor, but the engine.httpDo call is already running on the backgroundDispatcher.

saveTestDescriptors = {
saveTestDescriptors.invoke(it)
// TODO(aanorbel): show toast/snackbar
onBack()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we don't have logic in the Dependencies class where it's hard to find. Why not call onBack inside of the viewModel?

@aanorbel aanorbel requested a review from sdsantos September 10, 2024 10:16
@aanorbel aanorbel changed the title feat(android): bootstrap add descriptor page feat(run-v2): link installation Sep 10, 2024
@aanorbel aanorbel merged commit 327859e into main Sep 10, 2024
7 checks passed
@aanorbel aanorbel deleted the issues/52 branch September 10, 2024 14:56
@sdsantos sdsantos restored the issues/52 branch September 10, 2024 15:15
Copy link
Contributor

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug I found, you can only the same deeplink once. And I believe you should be able to re-open the same link.

android:scheme="https" />
</intent-filter>

<intent-filter android:autoVerify="true">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe we don't need the autoVerify here? Or we can still verify the ooni scheme?

Comment on lines +346 to +379
onCancel = {
snackbarHostState?.let {
showSnackbar(
scope = scope,
snackbarHostState = it,
message = cancelMessage,
)
}
onBack()
},
onError = {
snackbarHostState?.let {
showSnackbar(
scope = scope,
snackbarHostState = it,
message = errorMessage,
)
}
onBack()
},
saveTestDescriptors = {
saveTestDescriptors.invoke(it)
snackbarHostState?.let {
showSnackbar(
scope = scope,
snackbarHostState = it,
message = installCompleteMessage,
)
}
onBack()
},
fetchDescriptor = {
fetchDescriptor(descriptorId)
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it's not a good practice to have any sort of logic in the Dependencies class. We're not expecting to find it there, it's not testable, and it will make this file to be bloated very quickly.

Ideally this logic should be inside the ViewModel. Even the fetchDescriptor argument should just be something like fetchDescriptor = fetchDescriptor::invoke.

Comment on lines +347 to +353
snackbarHostState?.let {
showSnackbar(
scope = scope,
snackbarHostState = it,
message = cancelMessage,
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to show a snackbar saying the installation was cancelled? It felt a bit obvious to the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need it but i am trying to do backwards compatibility at once

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
}
}.onFailure {
onError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failure is not being logged, it might be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I am working on the update as we speak.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +19 to +21
.onOpenURL { url in
handleDeepLink(url: url)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong indentation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) = ComposeUIViewController {
App(
dependencies = dependencies,
deepLink = deepLinkFlow.collectAsState(null).value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only get a a deepLink once. Or does opening a deep link in iOS restart the whole app?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having some difficulties with this.

Comment on lines +180 to +183
val snackbarHostState = LocalSnackbarHostState.current
val cancelMessage = stringResource(Res.string.LoadingScreen_Runv2_Canceled)
val errorMessage = stringResource(Res.string.LoadingScreen_Runv2_Failure)
val installCompleteMessage = stringResource(Res.string.AddDescriptor_Toasts_Installed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ViewModel ends up with the code to trigger a snackbar, the actual code that fetches the strings and the SnackbarHostState should be in the View.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdsantos sdsantos deleted the issues/52 branch November 4, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run V2: Install Test
3 participants