Skip to content

Commit

Permalink
More random fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aamirazad committed Jul 8, 2024
1 parent a738b27 commit 5821b28
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
5 changes: 5 additions & 0 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ export async function getPaperlessDocuments(query: string) {

return data;
}

export async function formatWhishperName(name: string) {
const frontPart = name.split("_WHSHPR_")[1] ?? name;
return frontPart.replace(".m4a", "") ?? name;
}
2 changes: 1 addition & 1 deletion src/app/whishper/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
QueryClientProvider,
QueryClient,
} from "@tanstack/react-query";
import { getUserData } from "../actions";
import { formatWhishperName, getUserData } from "../actions";
import LoadingSpinner from "@/components/loading-spinner";
import type { WhishperRecordingType } from "@/types";
import OpenInternalLink from "@/components/internal-link";
Expand Down
49 changes: 28 additions & 21 deletions src/components/audio-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@tanstack/react-query";
import type { UsersTableType } from "@/server/db/schema";
import { Button } from "@/components/ui/button";
import { formatWhishperName } from "@/app/actions";

const queryClient = new QueryClient();

Expand All @@ -22,18 +23,20 @@ const fetchUserData = async (): Promise<UsersTableType> => {
function SkeletonLoader() {
return (
<div className="flex h-1/5 w-full justify-center">
<div className="flex h-full justify-center md:w-1/3">
<div className="flex h-full justify-center md:w-1/2">
<div className="flex h-full w-full flex-col rounded-xl bg-slate-600/50">
<div className="m-4 flex h-full flex-grow flex-col items-center justify-center">
{/* Long Pill Skeleton */}
<div className="mb-2 flex w-full flex-grow justify-center">
<div className="h-12 w-full animate-pulse rounded-full bg-gray-400 md:w-3/4"></div>
<div className="m-4 flex h-full flex-grow flex-col justify-center">
{/* Title Skeleton */}
<div className="h-6 w-3/4 animate-pulse rounded-md bg-gray-300"></div>
{/* Audio Skeleton */}
<div className="my-2 flex w-full flex-grow justify-center">
<div className="h-10 w-full animate-pulse rounded-md bg-gray-300 md:w-3/4"></div>
</div>
{/* Button Skeleton */}
<div className="flex animate-pulse justify-center gap-12">
<div className="h-10 w-24 rounded-md bg-gray-400" />
<div className="h-10 w-24 rounded-md bg-gray-400" />
<div className="h-10 w-24 rounded-md bg-gray-400" />
{/* Button Skeletons */}
<div className="flex w-full flex-shrink-0 justify-between">
<div className="h-10 w-24 animate-pulse rounded-md bg-gray-300"></div>
<div className="h-10 w-24 animate-pulse rounded-md bg-gray-300"></div>
<div className="h-10 w-24 animate-pulse rounded-md bg-gray-300"></div>
</div>
</div>
</div>
Expand All @@ -47,30 +50,34 @@ function AudioInfo(props: { name: string }) {

const {
data: userData,
isLoading,
isLoading: isUserDataLoading,
error,
} = useQuery({
queryKey: ["userData"],
queryFn: fetchUserData,
});

if (isLoading) {
const decodedName = decodeURIComponent(props.name);
const frontPart = decodedName.split("_WHSHPR_")[1] ?? decodedName;
const formattedName = frontPart.replace(".m4a", "") ?? decodedName;

if (isUserDataLoading) {
return <SkeletonLoader />;
}
if (!userData?.whishperURL ?? error) {
return <h1>Failed to get whishper url</h1>;
}

return (
<div className="flex h-1/5 w-full justify-center">
<div className="flex w-full justify-center">
<div className="flex h-full justify-center md:w-1/2">
<div className="flex h-full w-full flex-col rounded-xl bg-slate-600/50">
<div className="m-4 flex h-full flex-grow flex-col justify-center">
<div className="mb-4 w-full animate-pulse">
<div className="h-6 w-3/4 rounded-md bg-gray-500"></div>
</div>
<div className="m-4 flex h-full flex-grow flex-col justify-center gap-4">
<h1 className="h-6 w-3/4 rounded-md bg-gradient-to-r from-blue-500 to-purple-500 text-lg text-white">
{formattedName}
</h1>
{/* Audio */}
<div className="mb-2 flex w-full flex-grow justify-center">
<div className="flex w-full flex-grow justify-center">
<audio controls={true} className="w-full md:w-3/4">
<source
src={`${userData.whishperURL}/api/video/${props.name}`}
Expand All @@ -79,9 +86,9 @@ function AudioInfo(props: { name: string }) {
</audio>
</div>
<div className="flex w-full flex-shrink-0 animate-pulse justify-between">
<Button />
<Button />
<Button />
{Array.from({ length: 5 }, (_, index) => (
<Button key={index} />
))}
</div>
</div>
</div>
Expand Down
12 changes: 4 additions & 8 deletions src/components/document-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function SkeletonLoader() {
{/* PDF Skeleton */}
<div className="relative flex h-full flex-shrink flex-grow items-center justify-center rounded-lg">
{/* Pulsing Background */}
<div className="absolute inset-0 animate-pulse rounded-lg bg-gray-400"></div>
<div className="absolute inset-0 animate-pulse rounded-lg bg-gray-400" />
{/* Text Overlay */}
<div className="z-10 flex items-center justify-center">
<div className="text-center text-black">
Expand All @@ -74,13 +74,9 @@ function SkeletonLoader() {
</div>
{/* Button Skeleton */}
<div className="flex flex-shrink-0 animate-pulse flex-col gap-8">
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
<div className="h-10 w-24 rounded-md bg-gray-400"></div>
{Array.from({ length: 7 }, (_, index) => (
<div key={index} className="h-10 w-24 rounded-md bg-gray-400" />
))}
</div>
</div>
</div>
Expand Down

0 comments on commit 5821b28

Please sign in to comment.