Skip to content

Commit 8745304

Browse files
authored
Merge pull request #30 from 8JP8/fix-routing-and-voip-features-10337885148275067199
Fix 404 routing, Globe scrolling, and VoIP UI logic
2 parents 433652f + f5961fb commit 8745304

4 files changed

Lines changed: 42 additions & 15 deletions

File tree

frontend/components/ChatRoom/ChatRoomContainer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,8 @@ const ChatRoomContainer: React.FC<ChatRoomContainerProps> = ({
991991
{/* Action Buttons */}
992992
<div className="flex flex-wrap sm:flex-nowrap items-center gap-2 mt-2 sm:mt-0 w-full sm:w-auto">
993993
{/* VOIP Button */}
994-
{!room.is_public && (roomData?.voip_enabled ?? room.voip_enabled) && (
994+
{/* Logic: Group Chat (no topic_id) -> Always Show. Private Topic Chat -> Show if enabled. Public -> Hide. */}
995+
{((!room.topic_id) || (!room.is_public && (roomData?.voip_enabled ?? room.voip_enabled))) && (
995996
<div className="flex-1 sm:flex-none">
996997
<VoipButton
997998
roomId={room.id}

frontend/components/ChatRoom/ChatRoomMembersModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ const ChatRoomSettingsSection: React.FC<ChatRoomSettingsSectionProps> = ({
514514
aria-checked={voipEnabled}
515515
onClick={handleToggleVoip}
516516
disabled={updating}
517-
className={`${voipEnabled ? 'bg-blue-600' : 'bg-gray-200 dark:bg-gray-700'} relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-50`}
517+
className={`${voipEnabled ? 'bg-blue-600' : 'bg-gray-400 dark:bg-gray-600'} relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-50`}
518518
>
519519
<span
520520
aria-hidden="true"

frontend/components/UI/GlobeBackground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function GlobeBackgroundInner({ className = '' }: GlobeBackgroundProps) {
328328
}}
329329
width={1200}
330330
height={1200}
331-
className="w-full h-full opacity-0 transition-opacity duration-1000 pointer-events-auto"
331+
className="w-full h-full opacity-0 transition-opacity duration-1000 pointer-events-auto touch-pan-y"
332332
style={{
333333
contain: 'layout paint size',
334334
cursor: 'grab',

frontend/pages/index.tsx

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,37 +354,63 @@ export default function Home() {
354354
};
355355
}, [topics]); // Add topics dependency to find associated topic
356356

357-
// Handle deep linking via query params
357+
// Handle deep linking via query params and path (SPA fallback)
358358
useEffect(() => {
359359
if (!router.isReady) return;
360360

361361
const { chatRoomId, postId } = router.query;
362+
const path = router.asPath.split('?')[0];
362363

364+
// Handle Query Params (Legacy/Direct)
363365
if (chatRoomId) {
364-
// Remove query param to clean URL
365366
router.replace('/', undefined, { shallow: true });
366-
367367
const event = new CustomEvent('openChatRoom', { detail: { chatRoomId } });
368-
// Small delay to ensure listeners are ready/state is settled
369368
setTimeout(() => window.dispatchEvent(event), 100);
370-
} else if (postId) {
371-
// Remove query param
372-
router.replace('/', undefined, { shallow: true });
369+
return;
370+
}
373371

372+
if (postId) {
373+
router.replace('/', undefined, { shallow: true });
374374
const event = new CustomEvent('openPost', { detail: { postId } });
375375
setTimeout(() => window.dispatchEvent(event), 100);
376-
} else if (router.query.topicId) {
376+
return;
377+
}
378+
379+
if (router.query.topicId) {
377380
const topicId = router.query.topicId as string;
378-
// Remove query param
379381
router.replace('/', undefined, { shallow: true });
380-
381-
// Find and select the topic
382382
const topic = topics.find(t => t.id === topicId);
383383
if (topic) {
384384
handleTopicSelect(topic);
385385
}
386+
return;
387+
}
388+
389+
// Handle Path-based Routing (SPA Fallback)
390+
// Only if we are effectively on the root page logic but the path is different
391+
if (path !== '/') {
392+
// Regex for /post/[id]
393+
const postMatch = path.match(/^\/post\/([a-zA-Z0-9_-]+)$/);
394+
if (postMatch) {
395+
const id = postMatch[1];
396+
const event = new CustomEvent('openPost', { detail: { postId: id } });
397+
setTimeout(() => window.dispatchEvent(event), 100);
398+
return;
399+
}
400+
401+
// Regex for /chat-room/[id]
402+
const chatMatch = path.match(/^\/chat-room\/([a-zA-Z0-9_-]+)$/);
403+
if (chatMatch) {
404+
const id = chatMatch[1];
405+
const event = new CustomEvent('openChatRoom', { detail: { chatRoomId: id } });
406+
setTimeout(() => window.dispatchEvent(event), 100);
407+
return;
408+
}
409+
410+
// If it's an unknown path served by index.html fallback, redirect to 404
411+
router.replace('/404');
386412
}
387-
}, [router.isReady, router.query, topics]);
413+
}, [router.isReady, router.query, router.asPath, topics]);
388414

389415

390416
// Socket listeners for badge counts

0 commit comments

Comments
 (0)