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

Fixes #1378 Update Talawa to give a meaningful message if the URL isn't available. #1380

Conversation

Ayush0Chaudhary
Copy link
Contributor

@Ayush0Chaudhary Ayush0Chaudhary commented Dec 30, 2022

What kind of change does this PR introduce?

Issue Number:

Fixes #1378
and kind of fixes #1370

Did you add tests for your changes?
Yes

Snapshots/Videos:

Screenrecording_20221231_035010.mp4

If relevant, did you update the documentation?
Didn't update the docs.

Summary
In this PR if this

if (result.hasException) {

If statement is true it gives a snackbar after 2sec It will prompt a snackbar. I have to add 2 seconds delay because we cannot prompt a snackbar while the widgets are building. Fix#1368

Does this PR introduce a breaking change?
NO

Other information
None

Have you read the contributing guide?
Yes

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

@Ayush0Chaudhary Ayush0Chaudhary force-pushed the Ayush0Chaudhary/url-err-handling branch from c22d593 to fc5bd1a Compare December 30, 2022 22:38
@palisadoes
Copy link
Contributor

Please fix the failing tests

@SiddheshKukade
Copy link
Member

@Ayush0Chaudhary actually, I can't understand the reason for adding 2-sec delay to the snackBar. We already have a Verify button to verify the server URL.

@Ayush0Chaudhary
Copy link
Contributor Author

Ayush0Chaudhary commented Dec 31, 2022

It only verify whether the url is working with http.get(uri) but https//:www.youtube.com will also clear this check

But in this implementation we check whether the data received is appropriate for us.

And 2 sec delay is because we cannot prompt snackbar if the widgets are still building

@Ayush0Chaudhary
Copy link
Contributor Author

Ayush0Chaudhary commented Dec 31, 2022

@SiddheshKukade I added these lines back
#1380 (comment)

Now the snackbar will be shown only once if the url added doesn't provide the correct data. Which otherwise would've just shown the loading icon

My goal here was to tell user that his url will not work.

And if timer wasn't added and showSnackBar was set to true
It shows this error on the screen

err

@Sagar2366

@Ayush0Chaudhary Ayush0Chaudhary requested review from SiddheshKukade and removed request for Sagar2366 January 1, 2023 21:29
@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2023

Codecov Report

Merging #1380 (21b2544) into develop (5b28a77) will increase coverage by 0.11%.
The diff coverage is 87.50%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           develop    #1380      +/-   ##
===========================================
+ Coverage    68.38%   68.50%   +0.11%     
===========================================
  Files          144      146       +2     
  Lines         7164     7207      +43     
===========================================
+ Hits          4899     4937      +38     
- Misses        2265     2270       +5     
Impacted Files Coverage Δ
lib/services/database_mutation_functions.dart 6.12% <0.00%> (-0.13%) ⬇️
lib/widgets/organization_list.dart 45.28% <0.00%> (-2.72%) ⬇️
lib/services/navigation_service.dart 58.82% <100.00%> (+12.66%) ⬆️
...model/pre_auth_view_models/set_url_view_model.dart 100.00% <100.00%> (ø)
lib/widgets/talawa_error_dialog.dart 100.00% <100.00%> (ø)
lib/widgets/talawa_error_widget.dart 100.00% <100.00%> (ø)
lib/views/pre_auth_screens/login.dart 100.00% <0.00%> (ø)
lib/views/pre_auth_screens/signup_details.dart 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@SiddheshKukade
Copy link
Member

@Ayush0Chaudhary Yes I got it thanks, changes are looking fine to me now.

SiddheshKukade
SiddheshKukade previously approved these changes Jan 4, 2023
@Ayush0Chaudhary
Copy link
Contributor Author

@palisadoes @SiddheshKukade Please ask @Sagar2366 for 1 more review?
When I asked for re-review from @SiddheshKukade his review got removed?

@SiddheshKukade
Copy link
Member

@palisadoes @SiddheshKukade Please ask @Sagar2366 for 1 more review? When I asked for re-review from @SiddheshKukade his review got removed?

@Ayush0Chaudhary I have already reviewed your changes.

@Ayush0Chaudhary
Copy link
Contributor Author

but it is showing At least 2 approving reviews are required by reviewers with write access for merge

@palisadoes
Copy link
Contributor

@Ayush0Chaudhary The code testing coverage has been reduced by -2.51% with this change. Please add the necessary tests to make sure that the coverage is maintained.

@Ayush0Chaudhary
Copy link
Contributor Author

will do asap!

@palisadoes
Copy link
Contributor

@Ayush0Chaudhary Is there a standardized function/class for all error messages? It would greatly help with creating a standardized look and feel for the app. Then we could create an issue to migrate all errors to the new methodology.

Is there a good best practice that we could follow for this?

@SiddheshKukade
Copy link
Member

@Ayush0Chaudhary Is there a standardized function/class for all error messages? It would greatly help with creating a standardized look and feel for the app. Then we could create an issue to migrate all errors to the new methodology.

Is there a good best practice that we could follow for this?

@palisadoes Sir, we can create a separate custom widget for it and we can name that as TalawaErrorDialogue which will take a string to show the error message on the screen

@palisadoes
Copy link
Contributor

@Ayush0Chaudhary Is there a standardized function/class for all error messages? It would greatly help with creating a standardized look and feel for the app. Then we could create an issue to migrate all errors to the new methodology.
Is there a good best practice that we could follow for this?

@palisadoes Sir, we can create a separate custom widget for it and we can name that as TalawaErrorDialogue which will take a string to show the error message on the screen

OK, @Ayush0Chaudhary please add this to this PR then we can open another issue to convert all our errors to use the new widget.

@Ayush0Chaudhary
Copy link
Contributor Author

OK @palisadoes sir, I'll add this Widget

@Ayush0Chaudhary
Copy link
Contributor Author

also we can specify custom error messages like below, just example


class Constants {
  /// USER AUTHENTICATION CONSTANTS
  static const String USER_AUTH_WRONG_CREDENTIALS =
      'Invalid Credentials, Please check.';
  static const String USER_AUTH_USER_NOT_FOUND =
      'User Not found, try Signing Up.';
  static const String USER_NOT_AUTHORIZED_TO_FETCH_USER =
      'You are not authorized to fetch this User';
  static const String USER_NOT_FOUND = 'No User Found';

  /// GENERIC FAILURE CONSTANTS
  static const String BAD_RESPONSE_FORMAT = 'Bad Response Format';
  static const String GENERIC_FAILURE =
      'Something Wrong Occured! Please try again.';
  static const String NO_INTERNET_CONNECTION = 'No Internet Connection';
  static const String HTTP_EXCEPTION = 'Unable to fetch response';
  static const String UNAUTHORIZED_EXCEPTION =
      'Unauthorized to fetch the resource.';
}

@palisadoes @SiddheshKukade

@palisadoes
Copy link
Contributor

also we can specify custom error messages like below, just example


class Constants {
  /// USER AUTHENTICATION CONSTANTS
  static const String USER_AUTH_WRONG_CREDENTIALS =
      'Invalid Credentials, Please check.';
  static const String USER_AUTH_USER_NOT_FOUND =
      'User Not found, try Signing Up.';
  static const String USER_NOT_AUTHORIZED_TO_FETCH_USER =
      'You are not authorized to fetch this User';
  static const String USER_NOT_FOUND = 'No User Found';

  /// GENERIC FAILURE CONSTANTS
  static const String BAD_RESPONSE_FORMAT = 'Bad Response Format';
  static const String GENERIC_FAILURE =
      'Something Wrong Occured! Please try again.';
  static const String NO_INTERNET_CONNECTION = 'No Internet Connection';
  static const String HTTP_EXCEPTION = 'Unable to fetch response';
  static const String UNAUTHORIZED_EXCEPTION =
      'Unauthorized to fetch the resource.';
}

@palisadoes @SiddheshKukade

Remember that we need to ensure that the errors work in the selected language that user selects. The widget and supporting code / data will to be adjusted to support this.

@Ayush0Chaudhary
Copy link
Contributor Author

Ayush0Chaudhary commented Jan 5, 2023

@SiddheshKukade @palisadoes their already exist a function to show snack bar

void showSnackBar(
String message, {
Duration duration = const Duration(seconds: 2),
}) {
ScaffoldMessenger.of(navigatorKey.currentContext!).showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
duration: duration,
content: Text(message),
),
);
}

Can you explain what you meant in
#1380 (comment)

import 'package:flutter/material.dart';
import 'package:get/get.dart';

class TalawaErrorWidget {
  static void showLight(String title, String message) {
    Get.snackbar(
      title,
      message,
      snackPosition: SnackPosition.BOTTOM,
      snackStyle: SnackStyle.FLOATING,
    );
  }

  static void showDark(String title, String message) {
    Get.snackbar(
      title,
      message,
      snackPosition: SnackPosition.BOTTOM,
      backgroundColor: Colors.black.withOpacity(0.8),
      colorText: Colors.white,
      snackStyle: SnackStyle.FLOATING,
    );
  }
}

Did you want something like this?

@Ayush0Chaudhary
Copy link
Contributor Author

@noman2002 I did as you asked.

@noman2002
Copy link
Member

@Ayush0Chaudhary code coverage has gone down to 68.0 which is less than the minimum coverage required to merge a pr. Please try achieve 100% coverage for the file you have modified.

@Ayush0Chaudhary
Copy link
Contributor Author

Screenshot from 2023-01-26 22-17-02

@noman2002 code coverage is 68.7 % now
I added the test for both the widget.

@Ayush0Chaudhary
Copy link
Contributor Author

@palisadoes @noman2002 @TheHazeEffect @SiddheshKukade please review the PR

@noman2002
Copy link
Member

@Ayush0Chaudhary As the codecov is not getting triggered please attach a screenshot of code coverage of the files you have made changes, to get this PR approved. It will be easier for mentors to review.

@Ayush0Chaudhary
Copy link
Contributor Author

Ayush0Chaudhary commented Jan 27, 2023

For Set Url
Screenshot from 2023-01-28 02-33-01
Screenshot from 2023-01-28 02-33-07

@Ayush0Chaudhary
Copy link
Contributor Author

For Talawa Error Widget (custom snackbar)
Screenshot from 2023-01-28 02-35-56

@Ayush0Chaudhary
Copy link
Contributor Author

For talawa Error Dialog
Screenshot from 2023-01-28 02-36-11

@Ayush0Chaudhary
Copy link
Contributor Author

For navigation service
Screenshot from 2023-01-28 02-39-01

the part I added

@Ayush0Chaudhary
Copy link
Contributor Author

Overall coverage increased to 68.7% now
Screenshot from 2023-01-28 02-41-40

@Ayush0Chaudhary
Copy link
Contributor Author

@noman2002 I added the code coverage of the test I added.
@palisadoes @TheHazeEffect @SiddheshKukade

@noman2002
Copy link
Member

@Ayush0Chaudhary Please remove the firebase api files it includes your api keys. Rest everything looks good to me.

@Ayush0Chaudhary
Copy link
Contributor Author

@noman2002 done!! can we merge it now??

@noman2002
Copy link
Member

@noman2002 done!! can we merge it now??

Do we need to change anything in the installation process?

@Ayush0Chaudhary
Copy link
Contributor Author

@noman2002 done!! can we merge it now??

Do we need to change anything in the installation process?

no, the process remains the same

Copy link
Member

@noman2002 noman2002 left a comment

Choose a reason for hiding this comment

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

@palisadoes Looks good to me. Please have a look at it as there are various files changed.

@palisadoes palisadoes merged commit eeabcb5 into PalisadoesFoundation:develop Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants