mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can reload survey
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user