PostHog last fixes hopefully
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
@@ -21,9 +23,17 @@ class PermissionsProvider extends ChangeNotifier {
|
||||
Resource<UserAccess> _userAccess = Resource(data: null, isLoading: false, error: null);
|
||||
late OrganizationsProvider _organizations;
|
||||
bool _isLoaded = false;
|
||||
String? _loadedOrgRef;
|
||||
//For permissions to auto-load when an organization is set, so the dashboard no longer hangs waiting for permissions to become ready.
|
||||
|
||||
void update(OrganizationsProvider venue) {
|
||||
_organizations = venue;
|
||||
// Trigger a reload when organization changes or when permissions were never loaded.
|
||||
if (_organizations.isOrganizationSet &&
|
||||
_loadedOrgRef != _organizations.current.id &&
|
||||
!_userAccess.isLoading) {
|
||||
unawaited(load());
|
||||
}
|
||||
}
|
||||
|
||||
// Generic wrapper to perform service calls and reload state
|
||||
@@ -56,6 +66,7 @@ class PermissionsProvider extends ChangeNotifier {
|
||||
_userAccess = _userAccess.copyWith(data: allAccess, isLoading: false);
|
||||
}
|
||||
_isLoaded = true;
|
||||
_loadedOrgRef = orgRef;
|
||||
} catch (e) {
|
||||
_userAccess = _userAccess.copyWith(
|
||||
error: e is Exception ? e : Exception(e.toString()),
|
||||
@@ -164,6 +175,7 @@ class PermissionsProvider extends ChangeNotifier {
|
||||
void reset() {
|
||||
_userAccess = Resource(data: null, isLoading: false, error: null);
|
||||
_isLoaded = false;
|
||||
_loadedOrgRef = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user