1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Can reload survey

This commit is contained in:
2020-05-18 19:15:16 +02:00
parent e0d69ab504
commit b337e632bd
4 changed files with 25 additions and 4 deletions

View File

@ -13,9 +13,14 @@ import 'package:pie_chart/pie_chart.dart';
class SurveyWidget extends StatefulWidget {
final Survey survey;
final Function(Survey) onUpdated;
const SurveyWidget({Key key, @required this.survey})
: assert(survey != null),
const SurveyWidget({
Key key,
@required this.survey,
@required this.onUpdated,
}) : assert(survey != null),
assert(onUpdated != null),
super(key: key);
@override
@ -160,6 +165,14 @@ class _SurveyWidgetState extends SafeState<SurveyWidget> {
});
}
/// Reload survey information
///
/// Throws in case of failure
Future<void> _reloadSurvey() async {
final newSurvey = await SurveyHelper.getSurveyInfo(widget.survey.postID);
widget.onUpdated(newSurvey);
}
/// Create a new choice
void _createNewChoices() async {
try {
@ -176,7 +189,7 @@ class _SurveyWidgetState extends SafeState<SurveyWidget> {
await SurveyHelper.createNewChoice(survey.postID, newChoice);
// TODO : reload survey
await _reloadSurvey();
} catch (e, s) {
print("Could not create new survey choice! $e\n$s");
showSimpleSnack(