mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
fix: refactor code as suggested for performance
This commit is contained in:
parent
f85a6c0d7d
commit
e16b5136ac
2 changed files with 3 additions and 8 deletions
|
@ -414,15 +414,8 @@ export default defineNuxtComponent({
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const seededQuery = computed(() => {
|
|
||||||
return {
|
|
||||||
...props.query,
|
|
||||||
_searchSeed: Date.now().toString(),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
async function navigateRandom() {
|
async function navigateRandom() {
|
||||||
const recipe = await getRandom(seededQuery.value, queryFilter.value);
|
const recipe = await getRandom(props.query, queryFilter.value);
|
||||||
if (!recipe?.slug) {
|
if (!recipe?.slug) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ export const useLazyRecipes = function (publicGroupSlug: string | null = null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRandom(query: RecipeSearchQuery | null = null, queryFilter: string | null = null) {
|
async function getRandom(query: RecipeSearchQuery | null = null, queryFilter: string | null = null) {
|
||||||
|
query = query || {};
|
||||||
|
query._searchSeed = query._searchSeed || Date.now().toString();
|
||||||
const { data } = await api.recipes.getAll(1, 1, getParams("random", "desc", null, query, queryFilter));
|
const { data } = await api.recipes.getAll(1, 1, getParams("random", "desc", null, query, queryFilter));
|
||||||
if (data?.items.length) {
|
if (data?.items.length) {
|
||||||
return data.items[0];
|
return data.items[0];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue