Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/(app)/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export default async function ProfilePage() {
return (
<ProfileDashboard
displayName={displayName}
initialDiscoverable={profile?.is_discoverable ?? true}
userId={profile?.id ?? null}
username={profile?.username ?? null}
/>
);
Expand Down
13 changes: 12 additions & 1 deletion src/components/app-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export function AppWorkspace({
: "Student";
const username =
authState.mode === "authenticated" ? authState.profile.username : null;
const userId =
authState.mode === "authenticated" ? authState.profile.id : null;
const isDiscoverable =
authState.mode === "authenticated"
? authState.profile.is_discoverable
: true;

if (!activeView) {
return fallback;
Expand Down Expand Up @@ -85,7 +91,12 @@ export function AppWorkspace({
id="profile"
key={`profile:${resetKeys["/app/profile"] ?? 0}`}
>
<ProfileDashboard displayName={displayName} username={username} />
<ProfileDashboard
displayName={displayName}
initialDiscoverable={isDiscoverable}
userId={userId}
username={username}
/>
</WorkspacePanel>
</div>
);
Expand Down
21 changes: 21 additions & 0 deletions src/components/friends/direct-messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ export function DirectMessages({
friends,
initialFriendId,
onConversationClosed,
onConversationOpenChange,
onUnreadCountChange,
remoteClient,
}: {
currentUserId: string | null;
friends: SocialFriend[];
initialFriendId: string | null;
onConversationClosed: () => void;
onConversationOpenChange?: (open: boolean) => void;
onUnreadCountChange?: (count: number) => void;
remoteClient: SupabaseClient | null;
}) {
const [conversations, setConversations] = useState<Conversation[]>([]);
Expand Down Expand Up @@ -173,6 +177,21 @@ export function DirectMessages({
friendsRef.current = friends;
}, [friends]);

useEffect(() => {
onConversationOpenChange?.(Boolean(selectedFriend));
}, [onConversationOpenChange, selectedFriend]);

useEffect(() => {
if (!hasLoadedConversationsRef.current) return;

onUnreadCountChange?.(
conversations.reduce(
(total, conversation) => total + conversation.unreadCount,
0,
),
);
}, [conversations, isLoadingConversations, onUnreadCountChange]);

const markConversationRead = useCallback(
async (friendId: string) => {
if (!remoteClient || !currentUserId) return;
Expand Down Expand Up @@ -449,6 +468,7 @@ export function DirectMessages({
}

function openConversation(friendId: string) {
onConversationOpenChange?.(true);
setSelectedFriendId(friendId);
setMessages([]);
setFeedback(null);
Expand All @@ -466,6 +486,7 @@ export function DirectMessages({
aria-label="Back to messages"
className="mac-focus inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-[var(--color-text-muted)]"
onClick={() => {
onConversationOpenChange?.(false);
setSelectedFriendId(null);
setMessages([]);
setFeedback(null);
Expand Down
Loading