Skip to content

Commit ab098bc

Browse files
author
fevra-dev
committed
Fix: Restore privacy level selector (Low/Medium/High)
- Show selector once loading complete (not dependent on privacyLevel being set) - Add fallback to 'medium' when privacyLevel is null - Pass loading state to MainView component
1 parent 64b46b7 commit ab098bc

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/popup/Popup.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export const Popup: React.FC = () => {
252252
enabled={enabled}
253253
privacyLevel={privacyLevel}
254254
detections={detections}
255+
loading={loading}
255256
toggleProtection={toggleProtection}
256257
changePrivacyLevel={changePrivacyLevel}
257258
colors={colors}
@@ -335,10 +336,11 @@ const MainView: React.FC<{
335336
enabled: boolean;
336337
privacyLevel: PrivacyLevel | null;
337338
detections: DetectionResult[];
339+
loading: boolean;
338340
toggleProtection: () => void;
339341
changePrivacyLevel: (level: PrivacyLevel) => void;
340342
colors: ReturnType<typeof getThemeColors>;
341-
}> = ({ domain, enabled, privacyLevel, detections, toggleProtection, changePrivacyLevel, colors }) => (
343+
}> = ({ domain, enabled, privacyLevel, detections, loading, toggleProtection, changePrivacyLevel, colors }) => (
342344
<div style={{
343345
padding: '20px',
344346
display: 'flex',
@@ -412,8 +414,8 @@ const MainView: React.FC<{
412414
)}
413415
</div>
414416

415-
{/* Privacy Level Selector - only show when data is loaded to prevent animation flash */}
416-
{enabled && privacyLevel && (
417+
{/* Privacy Level Selector - show when enabled and not loading */}
418+
{enabled && !loading && (
417419
<div style={{ marginTop: '16px' }}>
418420
<div style={{
419421
fontSize: '10px',
@@ -426,7 +428,9 @@ const MainView: React.FC<{
426428
</div>
427429
<div style={{ display: 'flex', gap: '6px' }}>
428430
{(['low', 'medium', 'high'] as PrivacyLevel[]).map((level) => {
429-
const isSelected = privacyLevel === level;
431+
// Use medium as default when privacyLevel hasn't loaded yet
432+
const currentLevel = privacyLevel || 'medium';
433+
const isSelected = currentLevel === level;
430434
return (
431435
<button
432436
key={level}
@@ -463,9 +467,9 @@ const MainView: React.FC<{
463467
color: colors.textTertiary,
464468
textAlign: 'center'
465469
}}>
466-
{privacyLevel === 'low' && '10-20ms delay'}
467-
{privacyLevel === 'medium' && '20-45ms delay'}
468-
{privacyLevel === 'high' && '40-80ms delay'}
470+
{(privacyLevel || 'medium') === 'low' && '10-20ms delay'}
471+
{(privacyLevel || 'medium') === 'medium' && '20-45ms delay'}
472+
{(privacyLevel || 'medium') === 'high' && '40-80ms delay'}
469473
</div>
470474
</div>
471475
)}

0 commit comments

Comments
 (0)