From 7d6b28b4a3a232335ee7e70fc661faa95376650a Mon Sep 17 00:00:00 2001 From: Ricky Stretch Date: Sun, 22 Mar 2026 14:06:46 -0400 Subject: [PATCH] build.sh compile bug fix --- frontend/src/components/Sidebar.jsx | 158 ---------------------------- 1 file changed, 158 deletions(-) diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx index fa43e6e..6ed950b 100644 --- a/frontend/src/components/Sidebar.jsx +++ b/frontend/src/components/Sidebar.jsx @@ -192,161 +192,3 @@ export default function Sidebar({ groups, activeGroupId, onSelectGroup, notifica ); } - -function useAppSettings() { - const [settings, setSettings] = useState({ app_name: 'jama', logo_url: '', color_avatar_public: '', color_avatar_dm: '' }); - const fetchSettings = () => { - api.getSettings().then(({ settings }) => setSettings(settings)).catch(() => {}); - }; - useEffect(() => { - fetchSettings(); - window.addEventListener('jama:settings-changed', fetchSettings); - return () => window.removeEventListener('jama:settings-changed', fetchSettings); - }, []); - useEffect(() => { - const name = settings.app_name || 'jama'; - const prefix = document.title.match(/^(\(\d+\)\s*)/)?.[1] || ''; - document.title = prefix + name; - const faviconUrl = settings.logo_url || '/icons/jama.png'; - let link = document.querySelector("link[rel~='icon']"); - if (!link) { link = document.createElement('link'); link.rel = 'icon'; document.head.appendChild(link); } - link.href = faviconUrl; - }, [settings]); - return settings; -} - -function formatTime(dateStr) { - if (!dateStr) return ''; - const date = parseTS(dateStr); - const now = new Date(); - const diff = now - date; - if (diff < 86400000 && date.getDate() === now.getDate()) { - return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); - } - if (diff < 604800000) { - return date.toLocaleDateString([], { weekday: 'short' }); - } - return date.toLocaleDateString([], { month: 'short', day: 'numeric' }); -} - -export default function Sidebar({ groups, activeGroupId, onSelectGroup, notifications, unreadGroups = new Map(), onNewChat, onProfile, onUsers, onSettings: onOpenSettings, onBranding, onGroupManager, onGroupsUpdated, isMobile, onAbout, onHelp, onlineUserIds = new Set(), features = {} }) { - const { user } = useAuth(); - const { connected } = useSocket(); - const toast = useToast(); - const settings = useAppSettings(); - - const allGroups = [ - ...(groups.publicGroups || []), - ...(groups.privateGroups || []) - ]; - - const publicFiltered = allGroups.filter(g => g.type === 'public'); - - const privateFiltered = [...allGroups.filter(g => g.type === 'private')].sort((a, b) => { - if (!a.last_message_at && !b.last_message_at) return 0; - if (!a.last_message_at) return 1; - if (!b.last_message_at) return -1; - return new Date(b.last_message_at) - new Date(a.last_message_at); - }); - - const getNotifCount = (groupId) => notifications.filter(n => n.groupId === groupId).length; - - const GroupItem = ({ group }) => { - const notifs = getNotifCount(group.id); - const unreadCount = unreadGroups.get(group.id) || 0; - const hasUnread = unreadCount > 0; - const isActive = group.id === activeGroupId; - const isOnline = !!group.is_direct && !!group.peer_id && (onlineUserIds instanceof Set ? onlineUserIds.has(Number(group.peer_id)) : false); - - return ( -
onSelectGroup(group.id)} - > -
- {group.is_direct && group.peer_avatar && !group.is_managed ? ( - {group.name} - ) : group.is_managed && group.is_multi_group ? ( -
MG
- ) : group.is_managed ? ( -
UG
- ) : ( -
- {group.type === 'public' ? '#' : group.is_direct ? (group.peer_real_name || group.name)[0]?.toUpperCase() : group.name[0]?.toUpperCase()} -
- )} - {isOnline && } -
-
-
- - {group.is_direct && group.peer_display_name - ? <>{group.peer_display_name} ({group.peer_real_name}) - : group.is_direct && group.peer_real_name ? group.peer_real_name : group.name} - - {group.last_message_at && ( - {formatTime(group.last_message_at)} - )} -
-
- - {(() => { - const preview = (group.last_message || '').replace(/@\[([^\]]+)\]/g, '@$1'); - if (!preview) return group.is_readonly ? '📢 Read-only' : 'No messages yet'; - const isOwn = group.last_message_user_id && user && group.last_message_user_id === user.id; - return isOwn ? <>You: {preview} : preview; - })()} - - {notifs > 0 && {notifs}} - {hasUnread && notifs === 0 && {unreadCount}} -
-
-
- ); - }; - - return ( -
-
- {!isMobile && ( - - )} -
- -
- {publicFiltered.length > 0 && ( -
-
PUBLIC MESSAGES
- {publicFiltered.map(g => )} -
- )} - {privateFiltered.length > 0 && ( -
-
MESSAGES
- {privateFiltered.map(g => )} -
- )} - {allGroups.length === 0 && ( -
- No chats yet -
- )} -
- - {isMobile && ( - - )} - - -
- ); -} \ No newline at end of file