Prevent crash when logging in #81

Merged
AmineB merged 3 commits from davidoskky/ReaderForSelfoss-multiplatform:login_crash into master 2022-10-22 19:54:01 +00:00
Contributor

Types of changes

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This is NOT translation related.

While running on some emulators I have seen that it sometimes crashes on login because it tries to make api calls on localhost.
Preventing those calls if not already logged in solves the problem.

I also moved the definition of dateUtils within the login function so that it gets updated after logging in.

## Types of changes - [x] I have read the **CONTRIBUTING** document. - [x] My code follows the code style of this project. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed. - [x] This is **NOT** translation related. While running on some emulators I have seen that it sometimes crashes on login because it tries to make api calls on localhost. Preventing those calls if not already logged in solves the problem. I also moved the definition of dateUtils within the login function so that it gets updated after logging in.
davidoskky added 1 commit 2022-10-17 17:38:22 +00:00
Prevent crash when logging in
Some checks reported errors
continuous-integration/drone/pr Build was killed
c25e8889a4
AmineB requested changes 2022-10-17 17:44:44 +00:00
@ -47,3 +46,1 @@
updateApiVersion()
dateUtils = DateUtils(appSettingsService)
reloadBadges()
if (appSettingsService.getBaseUrl() != "") {
Owner

getBaseUrl should never return an empty string.

There is a verification done before even logging-in (and saving the settings), so this should never happen.

`getBaseUrl` should never return an empty string. There is a verification done before even logging-in (and saving the settings), so this should never happen.
Author
Contributor

The repository is initialized before logging in, at that point appSettingsService returns an empty string

The repository is initialized before logging in, at that point appSettingsService returns an empty string
Owner

Ok, so this is a workaround.

The issue is that the runBlocking block is called even when the user is'nt updated. This should be fixed.

Ok, so this is a workaround. The issue is that the `runBlocking` block is called even when the user is'nt updated. This should be fixed.
Author
Contributor

I could remove this from the init method and make a new public method which is called by the login activity after it checks that the user is correctly set.

I could remove this from the init method and make a new public method which is called by the login activity after it checks that the user is correctly set.
Owner

that could be better, yes !

that could be better, yes !
AmineB marked this conversation as resolved
@ -408,6 +409,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
appSettingsService.updateApiVersion(fetchedVersion.data.getApiMajorVersion())
}
}
dateUtils = DateUtils(appSettingsService)
Owner

why was this added ?

why was this added ?
Author
Contributor

If the repository is initialized before the login, this is required to initialize the dateUtils after logging in

If the repository is initialized before the login, this is required to initialize the dateUtils after logging in
AmineB marked this conversation as resolved
davidoskky added 2 commits 2022-10-21 20:56:45 +00:00
Adjust tests to changes in the repository
All checks were successful
continuous-integration/drone/pr Build is passing
667e9c1a5d
davidoskky requested review from AmineB 2022-10-21 20:57:36 +00:00
AmineB merged commit 510fcbe47e into master 2022-10-22 19:54:01 +00:00
davidoskky deleted branch login_crash 2022-10-23 01:57:39 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Louvorg/ReaderForSelfoss-multiplatform#81
No description provided.