Skip to content

Commit

Permalink
update: nesting the whole chat functionality to persist audio player
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceBaghel258025 committed Nov 18, 2023
1 parent 85440af commit 15247ab
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default async function Page() {
const { sessionClaims } = auth();
console.log("sessionClaims", sessionClaims?.organizations);
console.log(sessionClaims?.sub);
redirect(`/${sessionClaims?.sub}`);
redirect(`/usr/${sessionClaims?.sub}`);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions src/app/[uid]/layout.tsx → src/app/usr/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
import { Header } from "@/components/header";
export const dynamic = "force-dynamic",
revalidate = 0;
// export const dynamic = "force-dynamic",
// revalidate = 0;
import useStore from "@/store";
import { useEffect, useRef } from "react";
import { useRef, useEffect } from "react";

export default function LoggedInLayout({
children, // will be a page or nested layout
Expand All @@ -17,11 +17,13 @@ export default function LoggedInLayout({
if (store.audioSrc && audioRef.current) {
audioRef.current.src = store.audioSrc;
audioRef.current.load();
audioRef.current.play();
}
if (!store.audioSrc) {
audioRef.current?.pause();
}
}, [store.audioSrc]);
console.log("from nested layout");

return (
<div className="relative">
Expand Down
5 changes: 4 additions & 1 deletion src/components/room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const RoomWrapper = (props: Props) => {
<div className="flex space-between mb-2">
<div className="flex items-center">
<Button variant="outline" className="mr-2" asChild>
<Link onClick={() => setShowLoading(true)} href={`/${props.uid}`}>
<Link
onClick={() => setShowLoading(true)}
href={`/usr/${props.uid}`}
>
{showLoading ? (
<CircleNotch className="w-4 h-4 animate-spin" />
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/components/startnewchatbutton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Startnewchatbutton = (props: Props) => {
method: "POST",
});
const data = await res.json();
router.push(`/${props.org_slug}/chat/${Number(data.newChatId)}`);
router.push(`/usr/${props.org_slug}/chat/${Number(data.newChatId)}`);
};

return (
Expand Down

0 comments on commit 15247ab

Please sign in to comment.