simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
@@ -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