mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 08:14:30 -04:00
fix: Optimize Recipe Favorites/Ratings (#6075)
This commit is contained in:
@@ -5,26 +5,31 @@ const userRatings = ref<UserRatingSummary[]>([]);
|
||||
const loading = ref(false);
|
||||
const ready = ref(false);
|
||||
|
||||
export const useUserSelfRatings = function () {
|
||||
const $auth = useMealieAuth();
|
||||
const api = useUserApi();
|
||||
const $auth = useMealieAuth();
|
||||
|
||||
export const useUserSelfRatings = function () {
|
||||
async function refreshUserRatings() {
|
||||
if (!$auth.user.value || loading.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
const api = useUserApi();
|
||||
|
||||
const { data } = await api.users.getSelfRatings();
|
||||
userRatings.value = data?.ratings || [];
|
||||
|
||||
loading.value = false;
|
||||
ready.value = true;
|
||||
}
|
||||
|
||||
async function setRating(slug: string, rating: number | null, isFavorite: boolean | null) {
|
||||
loading.value = true;
|
||||
const api = useUserApi();
|
||||
|
||||
const userId = $auth.user.value?.id || "";
|
||||
await api.users.setRating(userId, slug, rating, isFavorite);
|
||||
|
||||
loading.value = false;
|
||||
await refreshUserRatings();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user