Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
chore: remove un-necessary suspense queries (#890)
Ameer Al Ashhab801757a359b8
diff --git a/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx b/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsxindex f996f5652..e51715654 100644--- a/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx+++ b/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx@@ -1,7 +1,7 @@"use client";import type { Video } from "@cap/web-domain";-import { useSuspenseQuery } from "@tanstack/react-query";+import { useQuery } from "@tanstack/react-query";import { Effect, Exit } from "effect";import { useRouter } from "next/navigation";import { useRef, useState } from "react";@@ -105,50 +105,49 @@ export default function FolderVideosSection({});};- const { data: analyticsData, isLoading: isLoadingAnalytics } =- useSuspenseQuery({- queryKey: ["analytics", initialVideos.map((video) => video.id)],- queryFn: async () => {- if (!dubApiKeyEnabled || initialVideos.length === 0) {- return {};- }-- const analyticsPromises = initialVideos.map(async (video) => {- try {- const response = await fetch(`/api/analytics?videoId=${video.id}`, {- method: "GET",- headers: {- "Content-Type": "application/json",- },- });-- if (response.ok) {- const responseData = await response.json();- return { videoId: video.id, count: responseData.count || 0 };- }- return { videoId: video.id, count: 0 };- } catch (error) {- console.warn(- `Failed to fetch analytics for video ${video.id}:`,- error,- );- return { videoId: video.id, count: 0 };+ const { data: analyticsData, isLoading: isLoadingAnalytics } = useQuery({+ queryKey: ["analytics", initialVideos.map((video) => video.id)],+ queryFn: async () => {+ if (!dubApiKeyEnabled || initialVideos.length === 0) {+ return {};+ }++ const analyticsPromises = initialVideos.map(async (video) => {+ try {+ const response = await fetch(`/api/analytics?videoId=${video.id}`, {+ method: "GET",+ headers: {+ "Content-Type": "application/json",+ },+ });++ if (response.ok) {+ const responseData = await response.json();+ return { videoId: video.id, count: responseData.count || 0 };}- });+ return { videoId: video.id, count: 0 };+ } catch (error) {+ console.warn(+ `Failed to fetch analytics for video ${video.id}:`,+ error,+ );+ return { videoId: video.id, count: 0 };+ }+ });- const results = await Promise.allSettled(analyticsPromises);- const analyticsData: Record<string, number> = {};+ const results = await Promise.allSettled(analyticsPromises);+ const analyticsData: Record<string, number> = {};- results.forEach((result) => {- if (result.status === "fulfilled" && result.value) {- analyticsData[result.value.videoId] = result.value.count;- }- });- return analyticsData;- },- staleTime: 30000, // 30 seconds- refetchOnWindowFocus: false,- });+ results.forEach((result) => {+ if (result.status === "fulfilled" && result.value) {+ analyticsData[result.value.videoId] = result.value.count;+ }+ });+ return analyticsData;+ },+ staleTime: 30000, // 30 seconds+ refetchOnWindowFocus: false,+ });const analytics = analyticsData || {};diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsxindex f1a538950..b5afbb268 100644--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx@@ -5,7 +5,7 @@ import { Button } from "@cap/ui";import type { Video } from "@cap/web-domain";import { faFolderPlus, faInfoCircle } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { useSuspenseQuery } from "@tanstack/react-query";+import { useQuery } from "@tanstack/react-query";import { useRouter, useSearchParams } from "next/navigation";import { useState } from "react";import { useDashboardContext } from "../../Contexts";@@ -91,7 +91,7 @@ export const SharedCaps = ({const organizationMemberCount = organizationMembers?.length || 0;- const { data: analyticsData } = useSuspenseQuery({+ const { data: analyticsData } = useQuery({queryKey: ["analytics", data.map((video) => video.id)],queryFn: async () => {if (!dubApiKeyEnabled || data.length === 0) {