From 0d3e9862d6e24a4235f2ee620e9aa2bad1a4e123 Mon Sep 17 00:00:00 2001 From: Kevin Hoang Date: Mon, 4 Dec 2023 20:06:28 -0600 Subject: [PATCH] cleaning up electron store --- release/app/package-lock.json | 4 +-- src/main/main.ts | 34 ++----------------- .../components/settings/SettingsMain.tsx | 2 ++ .../settings/app/SelectDefaultView.tsx | 33 ++++++++++++++++++ src/renderer/context/MainViewContext.tsx | 2 +- src/renderer/store.ts | 6 ---- 6 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 src/renderer/components/settings/app/SelectDefaultView.tsx diff --git a/release/app/package-lock.json b/release/app/package-lock.json index 743c32d..9e98e64 100644 --- a/release/app/package-lock.json +++ b/release/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "anicour", - "version": "1.0.1", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "anicour", - "version": "1.0.1", + "version": "1.0.0", "hasInstallScript": true, "license": "GPL-3.0" } diff --git a/src/main/main.ts b/src/main/main.ts index b54015b..a25160e 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -39,7 +39,7 @@ const schema: any = { }, listServiceType: { type: 'string', - default: 'MyAnimeList', + default: 'AniList', }, newsServiceType: { type: 'string', @@ -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', diff --git a/src/renderer/components/settings/SettingsMain.tsx b/src/renderer/components/settings/SettingsMain.tsx index 22c5d3e..232a9ef 100644 --- a/src/renderer/components/settings/SettingsMain.tsx +++ b/src/renderer/components/settings/SettingsMain.tsx @@ -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) { @@ -53,6 +54,7 @@ function SettingsMainTab({ view }: any) { }} > + diff --git a/src/renderer/components/settings/app/SelectDefaultView.tsx b/src/renderer/components/settings/app/SelectDefaultView.tsx new file mode 100644 index 0000000..465c7b6 --- /dev/null +++ b/src/renderer/components/settings/app/SelectDefaultView.tsx @@ -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 ( + + + + Default View for Media Lists + + + + + + + + + ); +}; + +export default SelectDefaultView; diff --git a/src/renderer/context/MainViewContext.tsx b/src/renderer/context/MainViewContext.tsx index c24d2cb..6f28a5a 100644 --- a/src/renderer/context/MainViewContext.tsx +++ b/src/renderer/context/MainViewContext.tsx @@ -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 ( diff --git a/src/renderer/store.ts b/src/renderer/store.ts index b159220..93c0889 100644 --- a/src/renderer/store.ts +++ b/src/renderer/store.ts @@ -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);