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

[#13] [Integrate] As a logged-in user, I can see the Home screen when I relaunch the app #66

Merged
merged 6 commits into from
Aug 25, 2023

Conversation

Thieurom
Copy link
Collaborator

@Thieurom Thieurom commented Aug 23, 2023

What happened 👀

  • Implemented HasUserLoggedInUseCase.
  • Created SplashViewModel, which depends on HasUserLoggedInUseCase, and integrated with SplashScreen.
  • Updated implementation of SecureStorage and TokenDataSource.

Insight 📝

Ideally, if Dart supports static method on an abstract class:

abstract class Serializable {
  factory fromJson(Map<String, dynamic> json);  // <-- won't compile
  Map<String, dynamic> toJson();
}

To overcome this, I had to separate the serializer from the model (serializable), which I think it's not too bad. More detail read here 🙏

It decouples the serialization logic from the actual classes. That means better code readability because classes only contain methods that relate directly to the class — serializers can even be put into their own files.

The other issue was that I couldn't get some tests of TokenDataSource to run correctly. It returns

MissingStubError: 'getValue'
  No stub was found which matches the arguments of this method call:
  getValue({key: SecureStorageKey.apiToken, serializer: Instance of 'ApiTokenSerializer'})

Even I made the following call before that.

when(mockSecureStorage.getValue(
  key: SecureStorageKey.apiToken,
  serializer: ApiTokenSerializer(),
))

Not sure there's a mistake or a mockito thing. I'll keep investigating 🙏

Proof Of Work 📹

KeepLoggedIn.mp4

@Thieurom Thieurom self-assigned this Aug 23, 2023
@Thieurom Thieurom changed the title [WIP [WIP] [#13] [Integrate] As a logged-in user, I can see the Home screen when I relaunch the app Aug 23, 2023
@Thieurom Thieurom added this to the 0.4.0 milestone Aug 23, 2023
@Thieurom Thieurom force-pushed the feature/13-integrate-keep-user-logged-in branch from 7a726bb to 69b2719 Compare August 24, 2023 07:02
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Patch coverage: 70.00% and project coverage change: +1.33% 🎉

Comparison is base (8b31157) 49.45% compared to head (51dddf1) 50.78%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #66      +/-   ##
===========================================
+ Coverage    49.45%   50.78%   +1.33%     
===========================================
  Files           33       36       +3     
  Lines          366      382      +16     
===========================================
+ Hits           181      194      +13     
- Misses         185      188       +3     
Flag Coverage Δ
unittests 50.78% <70.00%> (+1.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
lib/api/data_sources/token_data_source.dart 68.75% <0.00%> (-11.25%) ⬇️
lib/model/api_token.dart 54.54% <ø> (ø)
lib/storage/secure_storage.dart 0.00% <ø> (ø)
lib/storage/secure_storage_impl.dart 0.00% <0.00%> (ø)
lib/utils/serializer/api_token_serializer.dart 0.00% <0.00%> (ø)
lib/usecases/has_user_logged_in_use_case.dart 85.71% <85.71%> (ø)
lib/screens/splash/splash_view_model.dart 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Thieurom Thieurom force-pushed the feature/13-integrate-keep-user-logged-in branch from 69b2719 to f2de9fe Compare August 25, 2023 02:54
@Thieurom Thieurom changed the title [WIP] [#13] [Integrate] As a logged-in user, I can see the Home screen when I relaunch the app [#13] [Integrate] As a logged-in user, I can see the Home screen when I relaunch the app Aug 25, 2023
@Thieurom Thieurom marked this pull request as ready for review August 25, 2023 03:45
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

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

Only one tiny concern, the rest lgtm

return HasUserLoggedInUseCase(ref.watch(tokenDataSourceProvider));
});

class HasUserLoggedInUseCase implements NoParamsUseCase<bool> {

Choose a reason for hiding this comment

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

(Optional)

Suggested change
class HasUserLoggedInUseCase implements NoParamsUseCase<bool> {
class CheckUserLoggedInUseCase implements NoParamsUseCase<bool> {

Copy link
Collaborator

@nkhanh44 nkhanh44 left a comment

Choose a reason for hiding this comment

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

lgtm

lib/screens/splash/splash_screen.dart Outdated Show resolved Hide resolved
@Thieurom Thieurom force-pushed the feature/13-integrate-keep-user-logged-in branch from 51dddf1 to 492d7fe Compare August 25, 2023 07:19
@nkhanh44 nkhanh44 merged commit 5aa9335 into develop Aug 25, 2023
2 checks passed
@nkhanh44 nkhanh44 deleted the feature/13-integrate-keep-user-logged-in branch August 25, 2023 08:15
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.

[Integrate] As a logged-in user, I can see the Home screen when I relaunch the app
3 participants