Fix: Refresh status to dismiss notificiation

This commit is contained in:
Neeraj Gupta 2022-09-20 16:30:51 +05:30
parent aed002157c
commit b9f426ae4a
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
3 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,5 @@
import 'package:photos/events/event.dart';
// NotificationEvent event is used to re-fresh the UI to show latest notification
// (if any)
class NotificationEvent extends Event {}

View file

@ -5,7 +5,9 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sodium/flutter_sodium.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/events/notification_event.dart';
import 'package:photos/services/local_authentication_service.dart';
import 'package:photos/services/user_remote_flag_service.dart';
import 'package:photos/services/user_service.dart';
@ -52,6 +54,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
}
return;
}
Bus.instance.fire(NotificationEvent());
showToast(context, "Verification successful!");
await dialog.hide();
Navigator.of(context).pop();
@ -150,7 +153,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
"you have safely backed up your 24 word recovery key by re-entering it.",
style: Theme.of(context).textTheme.subtitle2,
),
const SizedBox(height: 8),
const SizedBox(height: 12),
TextFormField(
decoration: InputDecoration(
filled: true,
@ -175,7 +178,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
setState(() {});
},
),
const SizedBox(height: 8),
const SizedBox(height: 12),
Text(
"If you saved the recovery key from older app versions, you might have a 64 character recovery code instead of 24 words. You can enter that too.",
style: Theme.of(context).textTheme.caption,

View file

@ -5,6 +5,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/events/notification_event.dart';
import 'package:photos/events/sync_status_update_event.dart';
import 'package:photos/services/feature_flag_service.dart';
import 'package:photos/services/sync_service.dart';
@ -26,6 +27,7 @@ class StatusBarWidget extends StatefulWidget {
class _StatusBarWidgetState extends State<StatusBarWidget> {
StreamSubscription<SyncStatusUpdate> _subscription;
StreamSubscription<NotificationEvent> _notificationSubscription;
bool _showStatus = false;
bool _showErrorBanner = false;
@ -56,12 +58,19 @@ class _StatusBarWidgetState extends State<StatusBarWidget> {
});
}
});
_notificationSubscription =
Bus.instance.on<NotificationEvent>().listen((event) {
if (mounted) {
setState(() {});
}
});
super.initState();
}
@override
void dispose() {
_subscription.cancel();
_notificationSubscription.cancel();
super.dispose();
}