2020-11-24 06:54:00 -08:00
|
|
|
import React from "react";
|
|
|
|
import ReactDOM from "react-dom";
|
|
|
|
import CssBaseline from "@material-ui/core/CssBaseline";
|
|
|
|
import { Provider } from "react-redux";
|
|
|
|
import App from "./App";
|
|
|
|
import store from "./store";
|
|
|
|
import * as serviceWorker from "./serviceWorker";
|
2021-01-14 20:46:41 -08:00
|
|
|
import { saveState } from "./localStorage";
|
2021-01-22 22:16:48 -08:00
|
|
|
import { SettingsState } from "./reducers/settingsReducer";
|
2021-01-14 20:46:41 -08:00
|
|
|
|
2021-01-22 22:16:48 -08:00
|
|
|
let currentSettings: SettingsState | undefined = undefined;
|
2021-01-14 20:46:41 -08:00
|
|
|
store.subscribe(() => {
|
2021-01-22 22:16:48 -08:00
|
|
|
const prevSettings = currentSettings;
|
|
|
|
currentSettings = store.getState().settings;
|
|
|
|
|
|
|
|
// Write to local-storage only when settings have changed.
|
|
|
|
if (prevSettings !== currentSettings) {
|
|
|
|
saveState(store.getState());
|
|
|
|
}
|
2021-01-14 20:46:41 -08:00
|
|
|
});
|
2020-11-24 06:54:00 -08:00
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<React.StrictMode>
|
|
|
|
<CssBaseline />
|
|
|
|
<Provider store={store}>
|
2021-01-12 15:55:56 -08:00
|
|
|
<App />
|
2020-11-24 06:54:00 -08:00
|
|
|
</Provider>
|
|
|
|
</React.StrictMode>,
|
|
|
|
document.getElementById("root")
|
|
|
|
);
|
|
|
|
|
|
|
|
// If you want your app to work offline and load faster, you can change
|
|
|
|
// unregister() to register() below. Note this comes with some pitfalls.
|
|
|
|
// Learn more about service workers: https://bit.ly/CRA-PWA
|
|
|
|
// TODO(hibiken): Look into this.
|
|
|
|
serviceWorker.unregister();
|