mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 21:33:40 +08:00
added import export settings to the command line
This commit is contained in:
parent
7cf0a816fb
commit
4801edd1b4
2 changed files with 32 additions and 1 deletions
|
@ -16,6 +16,7 @@ import * as TagController from "./tag-controller";
|
|||
import * as PresetController from "./preset-controller";
|
||||
import * as Commandline from "./commandline";
|
||||
import * as CustomText from "./custom-text";
|
||||
import * as Settings from "./settings";
|
||||
|
||||
export let current = [];
|
||||
|
||||
|
@ -2009,6 +2010,32 @@ export let defaultCommands = {
|
|||
Commandline.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "importSettingsJSON",
|
||||
display: "Import settings JSON",
|
||||
input: true,
|
||||
exec: (input) => {
|
||||
try {
|
||||
UpdateConfig.apply(JSON.parse(input));
|
||||
UpdateConfig.saveToLocalStorage();
|
||||
Settings.update();
|
||||
Notifications.add("Done",1);
|
||||
} catch (e) {
|
||||
Notifications.add(
|
||||
"An error occured while importing settings: " + e,
|
||||
-1
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "exportSettingsJSON",
|
||||
display: "Export settings JSON",
|
||||
input: true,
|
||||
defaultValue:"",
|
||||
exec: (input) => {
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
@ -144,7 +144,11 @@ export async function saveToLocalStorage(noDbCheck = false) {
|
|||
// });
|
||||
let save = config;
|
||||
delete save.resultFilters;
|
||||
window.localStorage.setItem("config", JSON.stringify(save));
|
||||
let stringified = JSON.stringify(save);
|
||||
window.localStorage.setItem("config", stringified);
|
||||
CommandlineLists.defaultCommands.list.filter(
|
||||
(command) => command.id == "exportSettingsJSON"
|
||||
)[0].defaultValue = stringified;
|
||||
// restartCount = 0;
|
||||
if (!noDbCheck) await DB.saveConfig(save);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue