move api calls to created event (#559)

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-06-17 19:48:54 -08:00 committed by GitHub
parent 71a5de3432
commit d272784469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 70 additions and 55 deletions

View File

@ -48,32 +48,16 @@ export default {
},
},
async mounted() {
async created() {
// Initial API Requests
this.$store.dispatch("initTheme");
this.$store.dispatch("requestRecentRecipes");
this.$store.dispatch("refreshToken");
this.$store.dispatch("requestCurrentGroup");
this.$store.dispatch("requestUserData");
this.$store.dispatch("requestCategories");
this.$store.dispatch("requestCurrentGroup");
this.$store.dispatch("requestTags");
this.darkModeSystemCheck();
this.darkModeAddEventListener();
this.$store.dispatch("requestAppInfo");
this.$store.dispatch("requestCustomPages");
this.$store.dispatch("requestSiteSettings");
},
data() {
return {
refreshing: false,
registration: null,
snackBtnText: "",
snackWithBtnText: "",
snackWithButtons: false,
};
},
created() {
// Listen for swUpdated event and display refresh snackbar as required.
document.addEventListener("swUpdated", this.showRefreshUI, { once: true });
// Refresh all open app tabs when a new service worker is installed.
@ -86,6 +70,21 @@ export default {
}
},
mounted() {
this.darkModeSystemCheck();
this.darkModeAddEventListener();
},
data() {
return {
refreshing: false,
registration: null,
snackBtnText: "",
snackWithBtnText: "",
snackWithButtons: false,
};
},
methods: {
// For Later!

View File

@ -72,6 +72,13 @@ export default {
selected: [],
};
},
async created() {
if (this.tagSelector) {
this.$store.dispatch("requestTags");
} else {
this.$store.dispatch("requestCategories");
}
},
mounted() {
this.$emit(MOUNTED_EVENT);
this.setInit(this.value);

View File

@ -30,7 +30,7 @@ export default {
],
};
},
mounted() {
created() {
this.selectedItem = this.$store.getters.getActiveLang;
},
computed: {

View File

@ -122,7 +122,7 @@ export default {
}
},
},
async mounted() {
async created() {
await this.$store.dispatch("requestCurrentGroup");
await this.$store.dispatch("requestAllRecipes");
await this.buildMealStore();

View File

@ -82,7 +82,7 @@ export default {
} else return this.$t("settings.backup.partial-backup");
},
},
mounted() {
created() {
this.resetData();
this.getAvailableBackups();
},

View File

@ -78,15 +78,21 @@ export default {
hideImage: false,
};
},
mounted() {
this.getVersion();
created() {
this.showSidebar = !this.isMobile;
},
watch: {
user() {
this.hideImage = false;
},
isMain(val) {
if (val) {
this.$store.dispatch("requestCustomPages");
} else {
this.getVersion();
}
},
},
computed: {

View File

@ -75,7 +75,7 @@ export default {
prettyInfo: [],
};
},
async mounted() {
async created() {
await this.getInfo();
},
methods: {

View File

@ -89,7 +89,7 @@ export default {
return this.availableBackups.length;
},
},
mounted() {
created() {
this.getAvailableBackups();
},
methods: {

View File

@ -105,7 +105,7 @@ export default {
},
};
},
mounted() {
created() {
this.getStatistics();
},
methods: {

View File

@ -76,7 +76,7 @@ export default {
return this.group.users.length >= 1 ? true : false;
},
},
mounted() {
created() {
this.buildData();
},
methods: {

View File

@ -54,7 +54,7 @@ export default {
},
},
},
mounted() {
created() {
this.reqGroups();
},
methods: {

View File

@ -52,7 +52,7 @@ export default {
},
};
},
mounted() {
created() {
this.getAvailableMigrations();
},
methods: {

View File

@ -100,7 +100,7 @@ export default {
};
},
mounted() {
created() {
this.$store.dispatch("requestUserData");
},

View File

@ -160,7 +160,7 @@ export default {
},
},
async mounted() {
async created() {
this.getTodaysMeal();
await this.$store.dispatch("requestCurrentGroup");
this.getSiteSettings();

View File

@ -189,7 +189,7 @@ export default {
},
},
},
async mounted() {
async created() {
await this.getAllThemes();
},
methods: {

View File

@ -138,7 +138,7 @@ export default {
},
},
async mounted() {
async created() {
this.refreshProfile();
},

View File

@ -90,7 +90,7 @@ export default {
},
};
},
async mounted() {
async created() {
this.getPages();
},
methods: {

View File

@ -154,7 +154,7 @@ export default {
},
};
},
mounted() {
created() {
this.getOptions();
},
computed: {

View File

@ -67,7 +67,7 @@ export default {
tagsToAssign: [],
};
},
mounted() {
created() {
this.$store.dispatch("requestAllRecipes");
},
watch: {

View File

@ -157,7 +157,7 @@ export default {
],
};
},
mounted() {
created() {
this.getAllNotifications();
},
computed: {

View File

@ -67,7 +67,7 @@ export default {
},
},
},
mounted() {
created() {
this.refreshUnorganized();
},
methods: {

View File

@ -33,6 +33,11 @@ export default {
recipeByCategory: [],
};
},
async created() {
await this.$store.dispatch("requestRecentRecipes");
await this.buildPage();
this.recipeByCategory.sort((a, b) => a.position - b.position);
},
computed: {
siteSettings() {
return this.$store.getters.getSiteSettings;
@ -41,10 +46,7 @@ export default {
return this.$store.getters.getRecentRecipes;
},
},
async mounted() {
await this.buildPage();
this.recipeByCategory.sort((a, b) => a.position - b.position);
},
methods: {
async buildPage() {
await this.$store.dispatch("requestSiteSettings");

View File

@ -101,7 +101,7 @@ export default {
plannedMeals: [],
editMealPlan: null,
}),
async mounted() {
async created() {
this.requestMeals();
},
methods: {

View File

@ -45,7 +45,7 @@ export default {
mealPlan: {},
};
},
async mounted() {
async created() {
if (this.mealplanId) {
this.mealPlan = await api.mealPlans.getById(this.mealplanId);
} else {

View File

@ -28,7 +28,7 @@ export default {
defaultMessage: { details: "site failed to return valid schema" },
};
},
mounted() {
created() {
if (this.$route.query.test_url) {
this.getTestData();
}

View File

@ -130,12 +130,13 @@ export default {
};
},
async mounted() {
await this.getRecipeDetails();
created() {
this.getRecipeDetails();
this.jsonEditor = false;
this.form = this.$route.query.edit === "true" && this.loggedIn;
},
async mounted() {
this.checkPrintRecipe();
},

View File

@ -28,7 +28,7 @@ export default {
sortedResults: [],
};
},
async mounted() {
async created() {
if (this.allRecipes.length < 1) {
this.loading = true;
}

View File

@ -81,7 +81,7 @@ export default {
this.getRecipes();
},
},
mounted() {
created() {
this.getRecipes();
this.sortedResults = [];
},

View File

@ -58,7 +58,7 @@ export default {
},
},
async mounted() {
async created() {
await this.buildPage();
this.render = true;
},

View File

@ -34,7 +34,7 @@ export default {
}
},
},
async mounted() {
async created() {
this.userData = await api.users.getFavorites(this.$route.params.id);
this.sortedResults = [];
},

View File

@ -88,7 +88,7 @@ export default {
},
};
},
mounted() {
created() {
this.$store.dispatch("requestAllRecipes");
},
computed: {