mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Fix context issue
This commit is contained in:
parent
621efae92b
commit
90996d6be7
@ -1,4 +1,5 @@
|
||||
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/ui/dialogs/alert_dialog.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
@ -69,6 +70,8 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
listenChangeState<NewNumberUnreadConversations>((event) {});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -82,17 +82,19 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
||||
_error = false;
|
||||
});
|
||||
|
||||
await WebSocketHelper.connect();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
print("Attempting WebSocket connection...");
|
||||
|
||||
if (config().additionalLoading != null)
|
||||
await config().additionalLoading();
|
||||
|
||||
await WebSocketHelper.connect();
|
||||
|
||||
setState(() {});
|
||||
} catch (e, stack) {
|
||||
print("Could not connect to server! $e");
|
||||
|
@ -34,7 +34,8 @@ class StatusWidgetState extends SafeState<StatusWidget> {
|
||||
unreadNotifications = res.notifications;
|
||||
unreadConversations = res.conversations;
|
||||
|
||||
setState(() {});
|
||||
EventsHelper.emit(NewNumberNotifsEvent(unreadNotifications));
|
||||
EventsHelper.emit(NewNumberUnreadConversations(unreadConversations));
|
||||
} catch (e, s) {
|
||||
logError(e, s);
|
||||
print("Failed to initialize StatusWidget!");
|
||||
@ -46,11 +47,8 @@ class StatusWidgetState extends SafeState<StatusWidget> {
|
||||
super.initState();
|
||||
init();
|
||||
|
||||
listenChangeState<NewNumberNotifsEvent>(
|
||||
(e) => unreadNotifications = e.newNum);
|
||||
|
||||
listenChangeState<NewNumberUnreadConversations>(
|
||||
(e) => unreadConversations = e.newNum);
|
||||
listen<NewNumberNotifsEvent>((e) => unreadNotifications = e.newNum);
|
||||
listen<NewNumberUnreadConversations>((e) => unreadConversations = e.newNum);
|
||||
}
|
||||
|
||||
/// Find an ancestor of this object
|
||||
@ -58,8 +56,5 @@ class StatusWidgetState extends SafeState<StatusWidget> {
|
||||
c.findAncestorStateOfType<StatusWidgetState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
key: Key("$unreadNotifications-$unreadConversations"),
|
||||
child: widget.child(context),
|
||||
);
|
||||
Widget build(BuildContext context) => widget.child(context);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user