Skip to content

Commit

Permalink
Cleaning up some state calls
Browse files Browse the repository at this point in the history
  • Loading branch information
coltoneshaw committed Dec 1, 2021
1 parent 35bc92e commit 81d637f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/app/Pages/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const defaultTempProfile = {

const SettingsPage = () => {
const { currentProfile } = useAppSelector(state => state.config);

const [open, setOpen] = useState(false);
const handleClose = (event: any, reason: string) => {
if (reason === 'clickaway') return;
Expand Down
7 changes: 3 additions & 4 deletions src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ import { updateConfig } from '@/app/redux/configActions';
import { updateAllDataQuery } from './redux/threeCommas/Actions';

const App = () => {
// const classes = useStyles();

const themeEngine = useThemeProvidor();
const {currentProfile} = useAppSelector(state => state.config)
// const [updated, updateUpdated] = useState(() => false)
const currentProfile = useAppSelector(state => state.config.currentProfile)
const [profile, updateLocalProfile] = useState( () => currentProfile)
const { styles } = themeEngine

const dispatch = useAppDispatch()
// const dispatch = useAppDispatch()
useEffect(() => {
console.log('updating the config here')
updateConfig();
}, [dispatch]);

console.error('page is rerendering~')
useLayoutEffect(() => {
// if(updated) return
if(currentProfile.id == profile.id) return
Expand Down
4 changes: 2 additions & 2 deletions src/app/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import configSlice from './configSlice'
import threeCommasSlice from './threeCommas/threeCommasSlice'



const store = configureStore({
reducer: {
config: configSlice,
threeCommas: threeCommasSlice
}
},
devTools​: true
})

// Infer the `RootState` and `AppDispatch` types from the store itself
Expand Down
3 changes: 1 addition & 2 deletions src/main/Database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const chooseDatabase = (profileId: string) => new Database(path.join(appD
newRow[normalizeData(item)] = normalizeData(row[item])
})

const key = profileId + '-' + newRow.id
return {key, ...newRow}
return newRow
})

function update(table: string, data: any[], profileId: string): void {
Expand Down
25 changes: 20 additions & 5 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { config } from '@/main/Config/config';
// import isDev from 'electron-is-dev'; // New Import
const log = require('electron-log');


const path = require("path");
const isDev = !app.isPackaged;

import { menu } from './menu';

const { update, query, checkOrMakeTables, run, deleteAllData, upsert } = require('@/main/Database/database');

let win;

let win: BrowserWindow;

const {
default: installExtension,
REDUX_DEVTOOLS,
REACT_DEVELOPER_TOOLS
} = require("electron-devtools-installer");

const createWindow = (): void => {
win = new BrowserWindow({
Expand All @@ -36,9 +39,21 @@ const createWindow = (): void => {

let loadURL = `file://${__dirname}/index.html`
if (isDev) {
win.webContents.openDevTools();

// Errors are thrown if the dev tools are opened
// before the DOM is ready
win.webContents.once("dom-ready", async () => {
await installExtension([REDUX_DEVTOOLS, REACT_DEVELOPER_TOOLS])
.then((name:any) => console.log(`Added Extension: ${name}`))
.catch((err:any) => console.log("An error occurred: ", err))
.finally( () => win.webContents.openDevTools() )

});
loadURL = 'http://localhost:9000';
}

}


win.loadURL(loadURL);
}

Expand Down

0 comments on commit 81d637f

Please sign in to comment.