mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-23 15:31:37 -04:00
fix: Potential Fix for Global Timeline Server Error (#2372)
* simplified group id logic * moved onscroll listener to on-mounted
This commit is contained in:
parent
23786c1f5e
commit
20a78677ef
@ -40,7 +40,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, useAsync, useContext } from "@nuxtjs/composition-api";
|
import { defineComponent, onMounted, ref, useAsync, useContext } from "@nuxtjs/composition-api";
|
||||||
import { useThrottleFn, whenever } from "@vueuse/core";
|
import { useThrottleFn, whenever } from "@vueuse/core";
|
||||||
import RecipeTimelineItem from "./RecipeTimelineItem.vue"
|
import RecipeTimelineItem from "./RecipeTimelineItem.vue"
|
||||||
import { useTimelinePreferences } from "~/composables/use-users/preferences";
|
import { useTimelinePreferences } from "~/composables/use-users/preferences";
|
||||||
@ -104,25 +104,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.onscroll = () => {
|
|
||||||
// if the inner element is scrollable, let its scroll event handle the infiniteScroll
|
|
||||||
const timelineContainerElement = document.getElementById("timeline-container");
|
|
||||||
if (timelineContainerElement) {
|
|
||||||
const { clientHeight, scrollHeight } = timelineContainerElement
|
|
||||||
|
|
||||||
// if scrollHeight == clientHeight, the element is not scrollable, so we need to look at the global position
|
|
||||||
// if scrollHeight > clientHeight, it is scrollable and we don't need to do anything here
|
|
||||||
if (scrollHeight > clientHeight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const bottomOfWindow = document.documentElement.scrollTop + window.innerHeight >= document.documentElement.offsetHeight - (window.innerHeight*screenBuffer);
|
|
||||||
if (bottomOfWindow) {
|
|
||||||
infiniteScroll();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
whenever(
|
whenever(
|
||||||
() => props.value,
|
() => props.value,
|
||||||
() => {
|
() => {
|
||||||
@ -251,6 +232,29 @@ export default defineComponent({
|
|||||||
// preload events
|
// preload events
|
||||||
initializeTimelineEvents();
|
initializeTimelineEvents();
|
||||||
|
|
||||||
|
onMounted(
|
||||||
|
() => {
|
||||||
|
document.onscroll = () => {
|
||||||
|
// if the inner element is scrollable, let its scroll event handle the infiniteScroll
|
||||||
|
const timelineContainerElement = document.getElementById("timeline-container");
|
||||||
|
if (timelineContainerElement) {
|
||||||
|
const { clientHeight, scrollHeight } = timelineContainerElement
|
||||||
|
|
||||||
|
// if scrollHeight == clientHeight, the element is not scrollable, so we need to look at the global position
|
||||||
|
// if scrollHeight > clientHeight, it is scrollable and we don't need to do anything here
|
||||||
|
if (scrollHeight > clientHeight) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bottomOfWindow = document.documentElement.scrollTop + window.innerHeight >= document.documentElement.offsetHeight - (window.innerHeight*screenBuffer);
|
||||||
|
if (bottomOfWindow) {
|
||||||
|
infiniteScroll();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
deleteTimelineEvent,
|
deleteTimelineEvent,
|
||||||
loading,
|
loading,
|
||||||
|
@ -6,37 +6,34 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #title> {{ $t("recipe.group-global-timeline", { groupName }) }} </template>
|
<template #title> {{ $t("recipe.group-global-timeline", { groupName }) }} </template>
|
||||||
</BasePageTitle>
|
</BasePageTitle>
|
||||||
<RecipeTimeline v-model="ready" show-recipe-cards :query-filter="queryFilter" />
|
<RecipeTimeline v-if="queryFilter" v-model="ready" show-recipe-cards :query-filter="queryFilter" />
|
||||||
</v-sheet>
|
</v-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, useContext } from "@nuxtjs/composition-api";
|
import { defineComponent, ref } from "@nuxtjs/composition-api";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import RecipeTimeline from "~/components/Domain/Recipe/RecipeTimeline.vue";
|
import RecipeTimeline from "~/components/Domain/Recipe/RecipeTimeline.vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { RecipeTimeline },
|
components: { RecipeTimeline },
|
||||||
setup() {
|
setup() {
|
||||||
const { $auth } = useContext();
|
|
||||||
const api = useUserApi();
|
const api = useUserApi();
|
||||||
const ready = ref<boolean>(false);
|
const ready = ref<boolean>(false);
|
||||||
|
|
||||||
// @ts-expect-error - TS doesn't like the $auth global user attribute
|
|
||||||
const groupId: string = $auth.user.groupId;
|
|
||||||
const queryFilter = `recipe.group_id="${groupId}"`
|
|
||||||
|
|
||||||
const groupName = ref<string>("");
|
const groupName = ref<string>("");
|
||||||
async function refreshGroupName() {
|
const queryFilter = ref<string>("");
|
||||||
|
async function fetchGroup() {
|
||||||
const { data } = await api.groups.getCurrentUserGroup();
|
const { data } = await api.groups.getCurrentUserGroup();
|
||||||
if (data) {
|
if (data) {
|
||||||
|
queryFilter.value = `recipe.group_id="${data.id}"`;
|
||||||
groupName.value = data.name;
|
groupName.value = data.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ready.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshGroupName();
|
fetchGroup();
|
||||||
ready.value = true;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupName,
|
groupName,
|
||||||
queryFilter,
|
queryFilter,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user