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 ( -