Refresh Google calendars after OAuth return
This commit is contained in:
@@ -24,18 +24,48 @@ class AccountsPage extends StatefulWidget {
|
|||||||
State<AccountsPage> createState() => _AccountsPageState();
|
State<AccountsPage> createState() => _AccountsPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AccountsPageState extends State<AccountsPage> {
|
class _AccountsPageState extends State<AccountsPage> with WidgetsBindingObserver {
|
||||||
List<GoogleCalendarInfo> googleCalendars = [];
|
List<GoogleCalendarInfo> googleCalendars = [];
|
||||||
bool loadingCalendars = false;
|
bool loadingCalendars = false;
|
||||||
bool syncing = false;
|
bool syncing = false;
|
||||||
|
bool waitingForGoogleAuthReturn = false;
|
||||||
String? statusMessage;
|
String? statusMessage;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
_loadGoogleConnectionStatus();
|
_loadGoogleConnectionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant AccountsPage oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
final settingsChanged =
|
||||||
|
oldWidget.jarvisSettings.apiUrl != widget.jarvisSettings.apiUrl ||
|
||||||
|
oldWidget.jarvisSettings.apiToken != widget.jarvisSettings.apiToken ||
|
||||||
|
oldWidget.jarvisSettings.workspaceToken !=
|
||||||
|
widget.jarvisSettings.workspaceToken;
|
||||||
|
if (settingsChanged) {
|
||||||
|
_loadGoogleConnectionStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
super.didChangeAppLifecycleState(state);
|
||||||
|
if (state == AppLifecycleState.resumed && waitingForGoogleAuthReturn) {
|
||||||
|
waitingForGoogleAuthReturn = false;
|
||||||
|
_loadGoogleConnectionStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GoogleCalendarConnection? get connection =>
|
GoogleCalendarConnection? get connection =>
|
||||||
widget.connections.isEmpty ? null : widget.connections.first;
|
widget.connections.isEmpty ? null : widget.connections.first;
|
||||||
|
|
||||||
@@ -157,9 +187,10 @@ class _AccountsPageState extends State<AccountsPage> {
|
|||||||
if (!launched) throw Exception('Nem siker\u00fclt megnyitni a b\u00f6ng\u00e9sz\u0151t.');
|
if (!launched) throw Exception('Nem siker\u00fclt megnyitni a b\u00f6ng\u00e9sz\u0151t.');
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
waitingForGoogleAuthReturn = true;
|
||||||
loadingCalendars = false;
|
loadingCalendars = false;
|
||||||
statusMessage =
|
statusMessage =
|
||||||
'A Google enged\u00e9lyez\u00e9s b\u00f6ng\u00e9sz\u0151ben megny\u00edlt. Ha k\u00e9sz, t\u00e9rj vissza ide \u00e9s friss\u00edtsd a napt\u00e1rlist\u00e1t.';
|
'A Google enged\u00e9lyez\u00e9s b\u00f6ng\u00e9sz\u0151ben megny\u00edlt. Ha k\u00e9sz, t\u00e9rj vissza ide, \u00e9s automatikusan bet\u00f6lt\u00f6m a napt\u00e1rlist\u00e1t.';
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user