Skip to content

Commit

Permalink
feature: reset all settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mienaiyami committed Feb 26, 2023
1 parent 1d4fada commit e70dd23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
33 changes: 32 additions & 1 deletion src/Components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useAppDispatch, useAppSelector } from "../store/hooks";
import { resetShortcuts, setShortcuts } from "../store/shortcuts";
import { setOpenSetting } from "../store/isSettingOpen";
import { addBookmark, removeAllBookmarks } from "../store/bookmarks";
import { setAppSettings, setReaderSettings } from "../store/appSettings";
import { makeNewSettings, setAppSettings, setReaderSettings } from "../store/appSettings";

const Settings = (): ReactElement => {
const { promptSetDefaultLocation } = useContext(AppContext);
Expand Down Expand Up @@ -613,6 +613,37 @@ const Settings = (): ReactElement => {
>
Reset all themes
</button>
<button
onClick={() => {
window.dialog
.warn({
title: "Reset Settings",
message:
"This will reset all Settings (themes not included). Continue?",
noOption: false,
})
.then(({ response }) => {
if (response == undefined) return;
if (response === 1) return;
if (response === 0) {
window.dialog
.warn({
title: "Reset Settings",
noOption: false,
message:
"Are you really sure you want to reset settings?\nThis process is irreversible.",
})
.then((res) => {
if (res.response === 1) return;
dispatch(makeNewSettings());
dispatch(resetShortcuts());
});
}
});
}}
>
Reset all Settings
</button>
{/* <label className={appSettings.disableCachingCanvas ? "selected" : ""}>
<input
type="checkbox"
Expand Down
4 changes: 0 additions & 4 deletions src/MainImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type DeepArrayToUnion<T> = T extends T

// todo: use this as default settings by taking index 0 as default for arrays
export const settingValidatorData = {
bookmarksPath: "",
historyPath: "",
baseDir: "",
locationListSortType: ["normal", "inverse"],
/**
Expand Down Expand Up @@ -524,8 +522,6 @@ const themesPath = window.path.join(userDataURL, "themes.json");
const shortcutsPath = window.path.join(userDataURL, "shortcuts.json");

const defaultSettings: AppSettings = {
bookmarksPath,
historyPath,
baseDir: window.electron.app.getPath("home"),
locationListSortType: "normal",
updateCheckerEnabled: true,
Expand Down

0 comments on commit e70dd23

Please sign in to comment.