Skip to content

Commit

Permalink
🐛 Fix credentials list load issue (#2931)
Browse files Browse the repository at this point in the history
* always fetch credentials

* only fetch credentials once
  • Loading branch information
mutdmour authored Mar 4, 2022
1 parent c3f3e98 commit 3bc06ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ export interface ICredentialMap {
export interface ICredentialsState {
credentialTypes: ICredentialTypeMap;
credentials: ICredentialMap;
fetchedAllCredentials: boolean;
}

export interface ITagsState {
Expand Down
4 changes: 3 additions & 1 deletion packages/editor-ui/src/modules/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const module: Module<ICredentialsState, IRootState> = {
state: {
credentialTypes: {},
credentials: {},
fetchedAllCredentials: false,
},
mutations: {
setCredentialTypes: (state: ICredentialsState, credentialTypes: ICredentialType[]) => {
Expand All @@ -52,6 +53,7 @@ const module: Module<ICredentialsState, IRootState> = {

return accu;
}, {});
state.fetchedAllCredentials = true;
},
upsertCredential(state: ICredentialsState, credential: ICredentialsResponse) {
if (credential.id) {
Expand Down Expand Up @@ -130,7 +132,7 @@ const module: Module<ICredentialsState, IRootState> = {
context.commit('setCredentialTypes', credentialTypes);
},
fetchAllCredentials: async (context: ActionContext<ICredentialsState, IRootState>) => {
if (context.getters.allCredentials.length > 0) {
if (context.state.fetchedAllCredentials) {
return;
}
const credentials = await getAllCredentials(context.rootGetters.getRestApiContext);
Expand Down

0 comments on commit 3bc06ee

Please sign in to comment.