mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
optimize stores hydration calls (#16591)
This commit is contained in:
@@ -185,21 +185,18 @@ export default defineComponent({
|
||||
|
||||
async function deleteAndQuit() {
|
||||
await remove();
|
||||
await collectionsStore.hydrate();
|
||||
await fieldsStore.hydrate();
|
||||
await Promise.all([collectionsStore.hydrate(), fieldsStore.hydrate()]);
|
||||
router.replace(`/settings/data-model`);
|
||||
}
|
||||
|
||||
async function saveAndStay() {
|
||||
await save();
|
||||
await collectionsStore.hydrate();
|
||||
await fieldsStore.hydrate();
|
||||
await Promise.all([collectionsStore.hydrate(), fieldsStore.hydrate()]);
|
||||
}
|
||||
|
||||
async function saveAndQuit() {
|
||||
await save();
|
||||
await collectionsStore.hydrate();
|
||||
await fieldsStore.hydrate();
|
||||
await Promise.all([collectionsStore.hydrate(), fieldsStore.hydrate()]);
|
||||
router.push(`/settings/data-model`);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,18 +252,18 @@ export default defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const storeHydrations: Promise<void>[] = [];
|
||||
|
||||
const relations = getSystemRelations();
|
||||
|
||||
if (relations.length > 0) {
|
||||
for (const relation of relations) {
|
||||
await api.post('/relations', relation);
|
||||
}
|
||||
|
||||
await relationsStore.hydrate();
|
||||
const requests = relations.map((relation) => api.post('/relations', relation));
|
||||
await Promise.all(requests);
|
||||
storeHydrations.push(relationsStore.hydrate());
|
||||
}
|
||||
|
||||
await collectionsStore.hydrate();
|
||||
await fieldsStore.hydrate();
|
||||
storeHydrations.push(collectionsStore.hydrate(), fieldsStore.hydrate());
|
||||
await Promise.all(storeHydrations);
|
||||
|
||||
notify({
|
||||
title: t('collection_created'),
|
||||
|
||||
@@ -446,8 +446,7 @@ export default defineComponent({
|
||||
if (newLang && newLang !== locale.value) {
|
||||
await setLanguage(newLang);
|
||||
|
||||
await fieldsStore.hydrate();
|
||||
await collectionsStore.hydrate();
|
||||
await Promise.all([fieldsStore.hydrate(), collectionsStore.hydrate()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ export const useCollectionsStore = defineStore({
|
||||
|
||||
try {
|
||||
await api.delete(`/collections/${collection}`);
|
||||
await this.hydrate();
|
||||
await relationsStore.hydrate();
|
||||
await Promise.all([this.hydrate(), relationsStore.hydrate()]);
|
||||
|
||||
notify({
|
||||
title: i18n.global.t('delete_collection_success'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user