Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions src/context/SelectionContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ import { STORAGE_KEYS } from '../constants';

const SelectionContext = createContext();

export const SelectionProvider = ({ children }) => {
// State
const [selectedSoftware, setSelectedSoftware] = useState([]);
const [selectedConfigs, setSelectedConfigs] = useState([]);

// Load from localStorage on mount
useEffect(() => {
try {
const saved = localStorage.getItem(STORAGE_KEYS.selections);
if (saved) {
const data = JSON.parse(saved);
setSelectedSoftware(data.software || []);
setSelectedConfigs(data.configs || []);
}
} catch (error) {
console.error('Error loading selections from localStorage:', error);
// Load initial state from localStorage
const loadInitialSelections = () => {
try {
const saved = localStorage.getItem(STORAGE_KEYS.selections);
if (saved) {
const data = JSON.parse(saved);
return {
software: data.software || [],
configs: data.configs || [],
};
}
}, []);
} catch (error) {
console.error('Error loading selections from localStorage:', error);
}
return { software: [], configs: [] };
};

export function SelectionProvider({ children }) {
// State with lazy initialization
const [selectedSoftware, setSelectedSoftware] = useState(() => loadInitialSelections().software);
const [selectedConfigs, setSelectedConfigs] = useState(() => loadInitialSelections().configs);

// Save to localStorage on change
useEffect(() => {
Expand Down Expand Up @@ -118,13 +121,16 @@ export const SelectionProvider = ({ children }) => {
{children}
</SelectionContext.Provider>
);
};
}

SelectionProvider.displayName = 'SelectionProvider';

// Custom hook to use the selection context
export const useSelection = () => {
// eslint-disable-next-line react-refresh/only-export-components
export function useSelection() {
const context = useContext(SelectionContext);
if (!context) {
throw new Error('useSelection must be used within SelectionProvider');
}
return context;
};
}
10 changes: 7 additions & 3 deletions src/context/ThemeContext.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext, useState, useEffect } from 'react';

export const ThemeContext = createContext();
const ThemeContext = createContext();

export const ThemeProvider = ({ children }) => {
export function ThemeProvider({ children }) {
const [isDark, setIsDark] = useState(() => {
const saved = localStorage.getItem('theme');
return saved === 'dark';
Expand All @@ -27,4 +27,8 @@ export const ThemeProvider = ({ children }) => {
{children}
</ThemeContext.Provider>
);
};
}

ThemeProvider.displayName = 'ThemeProvider';

export { ThemeContext };
2 changes: 1 addition & 1 deletion src/data/software-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import vulkan from './software/runtimes/vulkan.js';
import onepassword from './software/security/1password.js';
import bitwarden from './software/security/bitwarden.js';
import keepassxc from './software/security/keepassxc.js';
import lastpass from './software/security-privacy/lastpass.js';
import lastpass from './software/security/lastpass.js';
import malwarebytes from './software/security/malwarebytes.js';
import nordvpn from './software/security/nordvpn.js';
import protonvpn from './software/security/protonvpn.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
"id": "lastpass",
"name": "LastPass",
"description": "Password manager",
"category": "security-privacy",
"category": "security",
"wingetId": "LastPass.LastPass",
"icon": "SiLastpass",
"iconColor": "#D32D27",
Expand Down
4 changes: 2 additions & 2 deletions src/generators/script-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { softwareCatalog, getSoftwareById } from '../data/software-catalog';
import { configurations, getConfigById } from '../data/configurations';
import { getSoftwareById } from '../data/software-catalog';
import { getConfigById } from '../data/configurations';
import { categories } from '../data/categories';

/**
Expand Down