From dc5a1721c3fcbfa53c8bc258d5c8547b80d47dc4 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:33:32 +0100 Subject: [PATCH] Refactor HistoryScrollList To use AnyHistory type and userOwnsHistory function --- client/src/components/History/HistoryScrollList.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/src/components/History/HistoryScrollList.vue b/client/src/components/History/HistoryScrollList.vue index 8198d3d7ebd..320fd832d70 100644 --- a/client/src/components/History/HistoryScrollList.vue +++ b/client/src/components/History/HistoryScrollList.vue @@ -9,7 +9,7 @@ import { storeToRefs } from "pinia"; import { computed, onMounted, onUnmounted, ref, watch } from "vue"; import { useRouter } from "vue-router/composables"; -import type { HistoryDetailed, HistorySummary } from "@/api"; +import { type AnyHistory, type HistorySummary, userOwnsHistory } from "@/api"; import { useAnimationFrameResizeObserver } from "@/composables/sensors/animationFrameResizeObserver"; import { useAnimationFrameScroll } from "@/composables/sensors/animationFrameScroll"; import { useHistoryStore } from "@/stores/historyStore"; @@ -121,11 +121,9 @@ watch( /** `historyStore` histories for current user */ const historiesProxy = ref([]); watch( - () => histories.value as HistoryDetailed[], - (h: HistoryDetailed[]) => { - historiesProxy.value = h.filter( - (h) => !h.user_id || (!currentUser.value?.isAnonymous && h.user_id === currentUser.value?.id) - ); + () => histories.value as AnyHistory[], + (h: AnyHistory[]) => { + historiesProxy.value = h.filter((h) => userOwnsHistory(currentUser.value, h)); }, { immediate: true,