🐛 Fix credentials list load issue (#2931)

* always fetch credentials

* only fetch credentials once
This commit is contained in:
Mutasem Aldmour 2022-03-04 19:39:52 +03:00 committed by GitHub
parent c3f3e98718
commit 3bc06ee5c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -764,6 +764,7 @@ export interface ICredentialMap {
export interface ICredentialsState { export interface ICredentialsState {
credentialTypes: ICredentialTypeMap; credentialTypes: ICredentialTypeMap;
credentials: ICredentialMap; credentials: ICredentialMap;
fetchedAllCredentials: boolean;
} }
export interface ITagsState { export interface ITagsState {

View file

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