File size: 1,179 Bytes
bf8b26e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { atom } from 'nanostores';
import { logStore } from './logs';

export type Theme = 'dark';

export const kTheme = 'bolt_theme';

export function themeIsDark() {
  return true; // Always return true since we only support dark mode
}

export const DEFAULT_THEME = 'dark';

export const themeStore = atom<Theme>(initStore());

function initStore(): Theme {
  if (!import.meta.env.SSR) {
    // Always force dark mode - ignore any persisted theme settings
    document.querySelector('html')?.setAttribute('data-theme', 'dark');

    // Clean up any old theme settings from localStorage
    localStorage.removeItem(kTheme);

    // Update user profile to remove theme settings
    try {
      const userProfile = localStorage.getItem('bolt_user_profile');

      if (userProfile) {
        const profile = JSON.parse(userProfile);
        delete profile.theme;
        localStorage.setItem('bolt_user_profile', JSON.stringify(profile));
      }
    } catch (error) {
      console.error('Error cleaning up user profile theme:', error);
    }

    return 'dark' as Theme;
  }

  return DEFAULT_THEME as Theme;
}

// Removed toggleTheme function since we only support dark mode