Skip to content

Commit

Permalink
remove unnecessary auto store to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Feb 26, 2025
1 parent 86ea636 commit aa7c1c2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
6 changes: 1 addition & 5 deletions packages/mui-system/src/cssVars/localStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ const localStorageManager: StorageManager = ({ key, storageWindow }) => {
}
let value;
try {
value = storageWindow.localStorage.getItem(key) || undefined;
if (!value) {
// the first time that user enters the site.
storageWindow.localStorage.setItem(key, defaultValue);
}
value = storageWindow.localStorage.getItem(key);
} catch {
// Unsupported
}
Expand Down
16 changes: 0 additions & 16 deletions packages/mui-system/src/cssVars/useCurrentColorScheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,6 @@ describe('useCurrentColorScheme', () => {
).to.equal(true);
});

it('save system mode', () => {
function Data() {
useCurrentColorScheme({
defaultMode: 'system',
defaultLightColorScheme: 'light',
defaultDarkColorScheme: 'dark',
supportedColorSchemes: ['light', 'dark'],
});
return null;
}
render(<Data />);
expect(window.localStorage.setItem.calledWith(DEFAULT_MODE_STORAGE_KEY, 'system')).to.equal(
true,
);
});

it('save lightColorScheme and darkColorScheme', () => {
function Data() {
const { setMode, setColorScheme, ...data } = useCurrentColorScheme({
Expand Down

0 comments on commit aa7c1c2

Please sign in to comment.