1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +00:00

Fix context issue

This commit is contained in:
Pierre HUBERT 2021-04-24 10:35:12 +02:00
parent 621efae92b
commit 90996d6be7
3 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,5 @@
import 'package:comunic/forez/helpers/forez_group_helper.dart'; import 'package:comunic/forez/helpers/forez_group_helper.dart';
import 'package:comunic/helpers/events_helper.dart';
import 'package:comunic/models/conversation.dart'; import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/dialogs/alert_dialog.dart'; import 'package:comunic/ui/dialogs/alert_dialog.dart';
import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart';
@ -69,6 +70,8 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
listenChangeState<NewNumberUnreadConversations>((event) {});
} }
@override @override

View File

@ -82,17 +82,19 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
_error = false; _error = false;
}); });
await WebSocketHelper.connect();
final prefs = await PreferencesHelper.getInstance(); final prefs = await PreferencesHelper.getInstance();
if (!prefs.getBool(PreferencesKeyList.IS_TOUR_SEEN)) if (!prefs.getBool(PreferencesKeyList.IS_TOUR_SEEN)) {
await WebSocketHelper.connect();
await showTour(context); await showTour(context);
}
print("Attempting WebSocket connection..."); print("Attempting WebSocket connection...");
if (config().additionalLoading != null) if (config().additionalLoading != null)
await config().additionalLoading(); await config().additionalLoading();
await WebSocketHelper.connect();
setState(() {}); setState(() {});
} catch (e, stack) { } catch (e, stack) {
print("Could not connect to server! $e"); print("Could not connect to server! $e");

View File

@ -34,7 +34,8 @@ class StatusWidgetState extends SafeState<StatusWidget> {
unreadNotifications = res.notifications; unreadNotifications = res.notifications;
unreadConversations = res.conversations; unreadConversations = res.conversations;
setState(() {}); EventsHelper.emit(NewNumberNotifsEvent(unreadNotifications));
EventsHelper.emit(NewNumberUnreadConversations(unreadConversations));
} catch (e, s) { } catch (e, s) {
logError(e, s); logError(e, s);
print("Failed to initialize StatusWidget!"); print("Failed to initialize StatusWidget!");
@ -46,11 +47,8 @@ class StatusWidgetState extends SafeState<StatusWidget> {
super.initState(); super.initState();
init(); init();
listenChangeState<NewNumberNotifsEvent>( listen<NewNumberNotifsEvent>((e) => unreadNotifications = e.newNum);
(e) => unreadNotifications = e.newNum); listen<NewNumberUnreadConversations>((e) => unreadConversations = e.newNum);
listenChangeState<NewNumberUnreadConversations>(
(e) => unreadConversations = e.newNum);
} }
/// Find an ancestor of this object /// Find an ancestor of this object
@ -58,8 +56,5 @@ class StatusWidgetState extends SafeState<StatusWidget> {
c.findAncestorStateOfType<StatusWidgetState>(); c.findAncestorStateOfType<StatusWidgetState>();
@override @override
Widget build(BuildContext context) => Container( Widget build(BuildContext context) => widget.child(context);
key: Key("$unreadNotifications-$unreadConversations"),
child: widget.child(context),
);
} }