-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fixed double entry bug when clicking safe homework button again after uploading #1699
Fixed double entry bug when clicking safe homework button again after uploading #1699
Conversation
Visit the preview URL for this PR (updated for commit cc53a53): https://sharezone-test--pr1699-double-homeworks-saf-cbxxkhdk.web.app (expires Tue, 13 Aug 2024 10:49:56 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b |
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.
Hey, thanks for your help! 💙
Right now I can't merge the PR since there is a warning from the Dart analyzer.
To fix this you could either change the _SaveButton
to a StatefulWidget
or use a StatefulBuilder
like shown here:
@override
Widget build(BuildContext context) {
bool isSaving = false;
return StatefulBuilder(builder: (context, setState) {
return SaveButton(
key: HwDialogKeys.saveButton,
tooltip: "Hausaufgabe speichern",
onPressed: isSaving
? null
: () {
setState(() => isSaving = true);
onPressed(context);
},
);
});
}
I would recommend using the StatefulBuilder
in this case. Additionally I disabled the save button in the case above instead of showing a SnackBar. I think its nicer this way.
Lastly I would be grateful if you could extract the changes to the CONTRIBUTING.md
into a seperate PR.
Thanks! :)
class _SaveButton extends StatelessWidget { | ||
const _SaveButton({this.editMode = false}); | ||
bool _homeworkIsSaving = false; | ||
_SaveButton({this.editMode = false}); | ||
|
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.
Since it's a stateless class you can't (or you shouldn't) use a mutable variable. This causes a warning to be shown, which is why the analyzer CI step is failing.
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.
Fixed
Are you sure that showing nothing is the better way? |
0113859
to
bde4d46
Compare
Yes, I tested it locally and I liked it better. Since there is a "sending data..." SnackBar anyways, the user knows that the data is in transit. |
Okay |
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.
LGTM! Thank you :)
setState(() => isSaving = true); | ||
onPressed(context); |
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.
I'm pretty sure this causes a bug if an error occurs during the upload (e.g. network issue) because then the save button is still disabled and the user can't retry.
I think the following change could fix it:
setState(() => isSaving = true);
await onPressed(context);
setState(() => isSaving = false);
Fixed bug #1117 and fixed some grammar mistakes in CONTRIBUTING.md