@firecms/user_management 3.0.0-canary.93 → 3.0.0-canary.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,19 +100,21 @@ export function useBuildUserManagement({
100
100
  if (!equal(newRoles, roles))
101
101
  setRoles(newRoles);
102
102
  } catch (e) {
103
+ setRoles([]);
103
104
  console.error("Error loading roles", e);
104
105
  setRolesError(e as Error);
105
106
  }
106
107
  setRolesLoading(false);
107
108
  },
108
109
  onError(e: any): void {
110
+ setRoles([]);
109
111
  console.error("Error loading roles", e);
110
112
  setRolesError(e);
111
113
  setRolesLoading(false);
112
114
  }
113
115
  });
114
116
 
115
- }, [dataSourceDelegate, rolesPath]);
117
+ }, [dataSourceDelegate?.initialised, rolesPath]);
116
118
 
117
119
  useEffect(() => {
118
120
  if (!dataSourceDelegate || !usersPath) return;
@@ -127,19 +129,21 @@ export function useBuildUserManagement({
127
129
  if (!equal(newUsers, usersWithRoleIds))
128
130
  setUsersWithRoleIds(newUsers);
129
131
  } catch (e) {
132
+ setUsersWithRoleIds([]);
130
133
  console.error("Error loading users", e);
131
134
  setUsersError(e as Error);
132
135
  }
133
136
  setUsersLoading(false);
134
137
  },
135
138
  onError(e: any): void {
139
+ setUsersWithRoleIds([]);
136
140
  console.error("Error loading users", e);
137
141
  setUsersError(e);
138
142
  setUsersLoading(false);
139
143
  }
140
144
  });
141
145
 
142
- }, [dataSourceDelegate, usersPath]);
146
+ }, [dataSourceDelegate?.initialised, usersPath]);
143
147
 
144
148
  const saveUser = useCallback(async (user: User): Promise<User> => {
145
149
  if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
@@ -170,7 +174,7 @@ export function useBuildUserManagement({
170
174
  values: data
171
175
  }).then(() => user);
172
176
  }
173
- }, [usersPath, dataSourceDelegate]);
177
+ }, [usersPath, dataSourceDelegate?.initialised]);
174
178
 
175
179
  const saveRole = useCallback((role: Role): Promise<void> => {
176
180
  if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
@@ -188,7 +192,7 @@ export function useBuildUserManagement({
188
192
  }).then(() => {
189
193
  return;
190
194
  });
191
- }, [rolesPath, dataSourceDelegate]);
195
+ }, [rolesPath, dataSourceDelegate?.initialised]);
192
196
 
193
197
  const deleteUser = useCallback(async (user: User): Promise<void> => {
194
198
  if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
@@ -201,7 +205,7 @@ export function useBuildUserManagement({
201
205
  values: {}
202
206
  };
203
207
  await dataSourceDelegate.deleteEntity({ entity })
204
- }, [usersPath, dataSourceDelegate]);
208
+ }, [usersPath, dataSourceDelegate?.initialised]);
205
209
 
206
210
  const deleteRole = useCallback(async (role: Role): Promise<void> => {
207
211
  if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
@@ -214,7 +218,7 @@ export function useBuildUserManagement({
214
218
  values: {}
215
219
  };
216
220
  await dataSourceDelegate.deleteEntity({ entity })
217
- }, [rolesPath, dataSourceDelegate]);
221
+ }, [rolesPath, dataSourceDelegate?.initialised]);
218
222
 
219
223
  const collectionPermissions: PermissionsBuilder = useCallback(({
220
224
  collection,