8dc4c4d072
Fixes N1–N94 findings from LOTUS_BUGS.md audit pass. Key changes: - ProfileDecoration: raw <button> → folds <Button> for save/remove; remove undefined --accent-cyan var - UserRoomProfile: textarea border uses color.SurfaceVariant.ContainerLine and config tokens instead of undefined --border-interactive var - LotusToastContainer: z-index raised from 9997 → 10001 so toasts appear above Night Light overlay (9998) and modals (9999) - Message.tsx: DeliveryStatus replaces Unicode glyphs with Icon components; MessageQuickReactions returns null instead of <span />; forward menu item gets correct size="100" on after icon - AudioContent: speed chip variant/radii now matches Play chip (Secondary/300) - ReadReceiptAvatars: pill border/radius/padding → folds config tokens; remove dead receipt-pill-btn className - EventReaders: Header size 600→500; close button gets radii="300"; borderBottom shorthand → borderBottomWidth token; remove raw fontSize - General.tsx: selected background/seasonal picker border uses color.Primary.Main instead of color.Critical.Main (error red) - RoomInsights: SectionHeader drops textTransform/letterSpacing/opacity; chart borderRadius → config tokens; remove raw fontSize:9; warning banner → SequenceCard - RoomProfile.tsx: formatting toolbar raw <button> → folds <Button>; topic read-mode renders formatted_body via sanitizeCustomHtml - MsgTypeRenderers: location Open button Chip→Button; opacity:0.65→priority - UploadCardRenderer: caption raw <input> → folds <Input> - VoiceMessageRecorder: replace undefined --bg-surface-variant/--tc-* vars with color.* tokens; replace bare <audio controls> with IconButton play/pause toggle - App.tsx: mention highlight uses WCAG 2.1 relative luminance (gamma linearization) instead of simplified approximation; border now rgba semi-transparent instead of same color as background - RoomNavItem: Mute MenuItem icon moved to before prop - SearchFilters: HasLink chip variant="Success" outlined to match filter bar - RoomViewHeader: Server Notice chip radii Pill→300; fix jotai import order - Fix ESLint import/order errors in DeviceVerificationSetup, RoomTopicViewer, MediaGallery, and RoomViewHeader Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
167 lines
6.0 KiB
TypeScript
167 lines
6.0 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import * as Sentry from '@sentry/react';
|
|
import { Provider as JotaiProvider, useAtomValue } from 'jotai';
|
|
import { OverlayContainerProvider, PopOutContainerProvider, TooltipContainerProvider } from 'folds';
|
|
import { RouterProvider } from 'react-router-dom';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
|
|
import { ClientConfigLoader } from '../components/ClientConfigLoader';
|
|
import { ClientConfigProvider } from '../hooks/useClientConfig';
|
|
import { ConfigConfigError, ConfigConfigLoading } from './ConfigConfig';
|
|
import { FeatureCheck } from './FeatureCheck';
|
|
import { createRouter } from './Router';
|
|
import { ScreenSizeProvider, useScreenSize } from '../hooks/useScreenSize';
|
|
import { useCompositionEndTracking } from '../hooks/useComposingCheck';
|
|
import { settingsAtom } from '../state/settings';
|
|
import { LotusToastContainer } from '../features/toast/LotusToastContainer';
|
|
import { useTauriNotificationBadge } from '../hooks/useTauriNotificationBadge';
|
|
import { SeasonalEffect } from '../components/seasonal/SeasonalEffect';
|
|
|
|
const FONT_MAP: Record<string, string> = {
|
|
system: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
inter: "'InterVariable', sans-serif",
|
|
'jetbrains-mono': "'JetBrains Mono', monospace",
|
|
'fira-code': "'Fira Code', monospace",
|
|
};
|
|
|
|
function AppearanceEffects() {
|
|
const settings = useAtomValue(settingsAtom);
|
|
|
|
useEffect(() => {
|
|
const color = settings.mentionHighlightColor;
|
|
if (color) {
|
|
document.body.style.setProperty('--mention-highlight-bg', color);
|
|
// WCAG 2.1 relative luminance with gamma linearization
|
|
const toLinear = (c: number) => {
|
|
const s = c / 255;
|
|
return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
};
|
|
const r = parseInt(color.slice(1, 3), 16);
|
|
const g = parseInt(color.slice(3, 5), 16);
|
|
const b = parseInt(color.slice(5, 7), 16);
|
|
const lum = 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
document.body.style.setProperty('--mention-highlight-text', lum > 0.179 ? '#000' : '#fff');
|
|
// Derive a visible border: same hue, reduced alpha
|
|
document.body.style.setProperty('--mention-highlight-border', `rgba(${r},${g},${b},0.5)`);
|
|
} else {
|
|
document.body.style.removeProperty('--mention-highlight-bg');
|
|
document.body.style.removeProperty('--mention-highlight-text');
|
|
document.body.style.removeProperty('--mention-highlight-border');
|
|
}
|
|
}, [settings.mentionHighlightColor]);
|
|
|
|
useEffect(() => {
|
|
const font = FONT_MAP[settings.fontFamily ?? 'inter'] ?? FONT_MAP.inter;
|
|
document.body.style.setProperty('--font-secondary', font);
|
|
}, [settings.fontFamily]);
|
|
|
|
return null;
|
|
}
|
|
|
|
function TauriEffects() {
|
|
useTauriNotificationBadge();
|
|
return null;
|
|
}
|
|
|
|
function NightLightOverlay() {
|
|
const settings = useAtomValue(settingsAtom);
|
|
if (!settings.nightLightEnabled) return null;
|
|
return (
|
|
<div
|
|
aria-hidden="true"
|
|
style={{
|
|
position: 'fixed',
|
|
inset: 0,
|
|
pointerEvents: 'none',
|
|
zIndex: 9998,
|
|
backgroundColor: `rgba(255, 140, 0, ${(settings.nightLightOpacity ?? 30) / 100})`,
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const queryClient = new QueryClient();
|
|
|
|
function App() {
|
|
const screenSize = useScreenSize();
|
|
useCompositionEndTracking();
|
|
|
|
const portalContainer = document.getElementById('portalContainer') ?? undefined;
|
|
|
|
return (
|
|
<Sentry.ErrorBoundary
|
|
fallback={({ error, resetError }) => (
|
|
<div
|
|
style={{
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
height: '100vh',
|
|
gap: '16px',
|
|
fontFamily: 'sans-serif',
|
|
padding: '24px',
|
|
textAlign: 'center',
|
|
}}
|
|
>
|
|
<h2 style={{ margin: 0 }}>Something went wrong</h2>
|
|
<p style={{ margin: 0, color: '#666', maxWidth: '400px' }}>
|
|
{error instanceof Error ? error.message : 'An unexpected error occurred.'}
|
|
</p>
|
|
<button
|
|
type="button"
|
|
onClick={resetError}
|
|
style={{
|
|
padding: '8px 20px',
|
|
borderRadius: '6px',
|
|
border: 'none',
|
|
background: '#5865f2',
|
|
color: '#fff',
|
|
cursor: 'pointer',
|
|
fontSize: '14px',
|
|
}}
|
|
>
|
|
Try again
|
|
</button>
|
|
</div>
|
|
)}
|
|
>
|
|
<TooltipContainerProvider value={portalContainer}>
|
|
<PopOutContainerProvider value={portalContainer}>
|
|
<OverlayContainerProvider value={portalContainer}>
|
|
<ScreenSizeProvider value={screenSize}>
|
|
<FeatureCheck>
|
|
<ClientConfigLoader
|
|
fallback={() => <ConfigConfigLoading />}
|
|
error={(err, retry, ignore) => (
|
|
<ConfigConfigError error={err} retry={retry} ignore={ignore} />
|
|
)}
|
|
>
|
|
{(clientConfig) => (
|
|
<ClientConfigProvider value={clientConfig}>
|
|
<QueryClientProvider client={queryClient}>
|
|
<JotaiProvider>
|
|
<AppearanceEffects />
|
|
<TauriEffects />
|
|
<RouterProvider router={createRouter(clientConfig, screenSize)} />
|
|
<SeasonalEffect />
|
|
<NightLightOverlay />
|
|
<LotusToastContainer />
|
|
</JotaiProvider>
|
|
<ReactQueryDevtools initialIsOpen={false} />
|
|
</QueryClientProvider>
|
|
</ClientConfigProvider>
|
|
)}
|
|
</ClientConfigLoader>
|
|
</FeatureCheck>
|
|
</ScreenSizeProvider>
|
|
</OverlayContainerProvider>
|
|
</PopOutContainerProvider>
|
|
</TooltipContainerProvider>
|
|
</Sentry.ErrorBoundary>
|
|
);
|
|
}
|
|
|
|
export default App;
|