simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -16,7 +16,7 @@ void showChatBubblePollSheet(
|
||||
required GetRoomResponseObject room,
|
||||
required int pollId,
|
||||
required String pollName,
|
||||
required void Function({bool renew}) refetch,
|
||||
required VoidCallback refetch,
|
||||
}) {
|
||||
showDetailsBottomSheet(
|
||||
context,
|
||||
@@ -36,7 +36,7 @@ void showChatBubblePollSheet(
|
||||
class _PollSheetBody extends StatefulWidget {
|
||||
final GetRoomResponseObject room;
|
||||
final int pollId;
|
||||
final void Function({bool renew}) refetch;
|
||||
final VoidCallback refetch;
|
||||
|
||||
const _PollSheetBody({
|
||||
required this.room,
|
||||
@@ -49,21 +49,13 @@ class _PollSheetBody extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PollSheetBodyState extends State<_PollSheetBody> {
|
||||
Future<GetPollStateResponse>? _future;
|
||||
late Future<GetPollStateResponse> _future = _fetch();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_future = GetPollState(token: widget.room.token, pollId: widget.pollId).run();
|
||||
}
|
||||
Future<GetPollStateResponse> _fetch() =>
|
||||
GetPollState(token: widget.room.token, pollId: widget.pollId).run();
|
||||
|
||||
void _reload() {
|
||||
setState(() {
|
||||
_future = GetPollState(
|
||||
token: widget.room.token,
|
||||
pollId: widget.pollId,
|
||||
).run();
|
||||
});
|
||||
setState(() => _future = _fetch());
|
||||
}
|
||||
|
||||
void _applyState(GetPollStateResponse state) {
|
||||
@@ -71,7 +63,7 @@ class _PollSheetBodyState extends State<_PollSheetBody> {
|
||||
// Block body: an arrow would return the Future, which setState rejects.
|
||||
_future = Future.value(state);
|
||||
});
|
||||
widget.refetch(renew: true);
|
||||
widget.refetch();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user