Skip to content

Commit

Permalink
cleaning up electron store
Browse files Browse the repository at this point in the history
  • Loading branch information
ReStartQ committed Dec 5, 2023
1 parent 23eed8e commit 0d3e986
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 3 additions & 31 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const schema: any = {
},
listServiceType: {
type: 'string',
default: 'MyAnimeList',
default: 'AniList',
},
newsServiceType: {
type: 'string',
Expand Down Expand Up @@ -70,45 +70,17 @@ const schema: any = {
default: 'Romaji',
},
defaultView: {
type: 'array',
default: [0, 1, 2],
},
defaultList: {
type: 'array',
default: [0, 1, 2],
type: 'number',
default: 0,
},
defaultLink: {
type: 'string',
default: 'AniList',
},
statusColors: {
type: 'string',
default: 'rbg',
},
showListLocation: {
type: 'boolean',
default: true,
},
advancedMedia: {
type: 'object',
default: {},
},
mediaList: {
type: 'object',
default: {},
},
isAdult: {
type: 'boolean',
default: false,
},
mediaListMarkings: {
type: 'object',
default: {},
},
defaultDateFormat: {
type: 'string',
default: 'MDY',
},
defaultAddStatus: {
type: 'string',
default: 'CURRENT',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/settings/SettingsMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import AccountSection from './services/AccountSection';
import AdultLabel from './app/AdultLabel';
import SelectDefaultLink from './app/SelectDefaultLink';
import DefaultStatus from './app/DefaultStatus';
import SelectDefaultView from './app/SelectDefaultView';

function SettingsMainTab({ view }: any) {
if (view === 0) {
Expand Down Expand Up @@ -53,6 +54,7 @@ function SettingsMainTab({ view }: any) {
}}
>
<SelectLanguage />
<SelectDefaultView />
<SelectDefaultLink />
<DefaultStatus />
</Box>
Expand Down
33 changes: 33 additions & 0 deletions src/renderer/components/settings/app/SelectDefaultView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Box, FormControl, InputLabel, NativeSelect } from '@mui/material';
import React from 'react';
import { useMainView } from 'renderer/context/MainViewContext';

const SelectDefaultView = () => {
const myMainView: any = useMainView();

const handleChange = (event: any) => {
myMainView.setView(event.target.value);
window.electron.store.set('defaultView', Number(event.target.value));
};

return (
<Box>
<FormControl fullWidth>
<InputLabel variant="standard" id="defaultLinkLabel">
Default View for Media Lists
</InputLabel>
<NativeSelect
id="defaultLinkSelect"
value={myMainView.view}
onChange={handleChange}
>
<option value={0}>Grid</option>
<option value={1}>Compact</option>
<option value={2}>List</option>
</NativeSelect>
</FormControl>
</Box>
);
};

export default SelectDefaultView;
2 changes: 1 addition & 1 deletion src/renderer/context/MainViewContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useMainView = () => {
export const MainViewContextProvider = ({
children,
}: MainViewContextProviderProps) => {
const [view, setView] = useState(0);
const [view, setView] = useState(window.electron.store.get('defaultView'));

return (
<MainViewContext.Provider value={{ view, setView }}>
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ myStore.set(isValidStartDateAtom, true);
export const isValidCompleteDateAtom = atom(true);
myStore.set(isValidCompleteDateAtom, true);

// can be 'MDY', 'YMD', 'DMY'
export const defaultDateFormat = atom(
window.electron.store.get('defaultDateFormat'),
);
myStore.set(defaultDateFormat, window.electron.store.get('defaultDateFormat'));

// 0 = info, 1 = success + add, 2 = success - delete
export const notificationTypeAtom = atom(0);
myStore.set(notificationTypeAtom, 0);
Expand Down

0 comments on commit 0d3e986

Please sign in to comment.