Organizations now load only once #38
@@ -35,6 +35,8 @@ class OrganizationsProvider extends ChangeNotifier {
|
|||||||
_setResource(_resource.copyWith(isLoading: true, error: null));
|
_setResource(_resource.copyWith(isLoading: true, error: null));
|
||||||
try {
|
try {
|
||||||
final orgs = await OrganizationService.list();
|
final orgs = await OrganizationService.list();
|
||||||
|
// keep fetched organizations so _org can resolve against them
|
||||||
|
_setResource(Resource(data: orgs, isLoading: true));
|
||||||
// fetch stored org
|
// fetch stored org
|
||||||
String? org = await SecureStorageService.get(Constants.currentOrgKey);
|
String? org = await SecureStorageService.get(Constants.currentOrgKey);
|
||||||
// check stored org availability
|
// check stored org availability
|
||||||
@@ -54,6 +56,7 @@ class OrganizationsProvider extends ChangeNotifier {
|
|||||||
_setResource(_resource.copyWith(isLoading: true, error: null));
|
_setResource(_resource.copyWith(isLoading: true, error: null));
|
||||||
try {
|
try {
|
||||||
final org = await OrganizationService.loadByInvitation(invitationRef);
|
final org = await OrganizationService.loadByInvitation(invitationRef);
|
||||||
|
_setResource(Resource(data: [org], isLoading: true));
|
||||||
await setCurrentOrganization(org.id);
|
await setCurrentOrganization(org.id);
|
||||||
_setResource(Resource(data: [org], isLoading: false));
|
_setResource(Resource(data: [org], isLoading: false));
|
||||||
return org;
|
return org;
|
||||||
|
|||||||
Reference in New Issue
Block a user