2024-05-26 07:33:35 +00:00
|
|
|
import storage from "./core/storage.js";
|
|
|
|
|
2022-05-29 02:58:42 +00:00
|
|
|
// All getters are async getter, all setter are sync setter,
|
|
|
|
// we just ignore the set promise.
|
2019-10-31 04:08:04 +00:00
|
|
|
const settings = {
|
2020-10-26 16:06:00 +00:00
|
|
|
get autoUpdate() {
|
2022-05-29 02:58:42 +00:00
|
|
|
return (async () => {
|
|
|
|
return await storage.getItem('auto-update') || false;
|
|
|
|
})();
|
2020-10-26 16:06:00 +00:00
|
|
|
},
|
|
|
|
set autoUpdate(mode) {
|
2022-05-29 02:58:42 +00:00
|
|
|
storage.setItem('auto-update', mode);
|
2020-10-26 16:06:00 +00:00
|
|
|
},
|
2019-10-31 04:08:04 +00:00
|
|
|
get isOfflineMode() {
|
2022-05-29 02:58:42 +00:00
|
|
|
return (async () => {
|
|
|
|
return await storage.getItem('offline-mode') || false;
|
|
|
|
})();
|
2019-10-31 04:08:04 +00:00
|
|
|
},
|
|
|
|
set isOfflineMode(mode) {
|
2022-05-29 02:58:42 +00:00
|
|
|
storage.setItem('offline-mode', mode);
|
2019-10-31 04:08:04 +00:00
|
|
|
},
|
|
|
|
get offlineDocPath() {
|
2022-05-29 02:58:42 +00:00
|
|
|
return (async () => {
|
2022-07-05 05:13:03 +00:00
|
|
|
return await storage.getItem('offline-path') || '';
|
2022-05-29 02:58:42 +00:00
|
|
|
})();
|
2019-10-31 04:08:04 +00:00
|
|
|
},
|
|
|
|
set offlineDocPath(path) {
|
2022-05-29 02:58:42 +00:00
|
|
|
storage.setItem('offline-path', path);
|
2019-10-31 04:08:04 +00:00
|
|
|
},
|
2020-05-01 03:46:13 +00:00
|
|
|
get crateRegistry() {
|
2022-05-29 02:58:42 +00:00
|
|
|
return (async () => {
|
|
|
|
return await storage.getItem("crate-registry") || "crates.io";
|
|
|
|
})();
|
2020-05-01 03:46:13 +00:00
|
|
|
},
|
|
|
|
set crateRegistry(value) {
|
2022-05-29 02:58:42 +00:00
|
|
|
storage.setItem("crate-registry", value);
|
2020-05-01 03:46:13 +00:00
|
|
|
},
|
2022-01-23 15:51:45 +00:00
|
|
|
get defaultSearch() {
|
2022-05-29 02:58:42 +00:00
|
|
|
return (async () => {
|
|
|
|
return await storage.getItem("default-search") || {
|
|
|
|
thirdPartyDocs: false,
|
|
|
|
docsRs: true,
|
|
|
|
attributes: true
|
|
|
|
};
|
|
|
|
})();
|
2022-01-23 15:51:45 +00:00
|
|
|
},
|
|
|
|
set defaultSearch(value) {
|
2022-05-29 02:58:42 +00:00
|
|
|
storage.setItem("default-search", value);
|
2022-08-17 14:30:34 +00:00
|
|
|
},
|
|
|
|
get showMacroRailroad() {
|
|
|
|
return (async () => {
|
|
|
|
let value = await storage.getItem("show-macro-railroad");
|
|
|
|
// Default to true.
|
|
|
|
return value === undefined ? true : value;
|
|
|
|
})();
|
|
|
|
},
|
|
|
|
set showMacroRailroad(value) {
|
|
|
|
storage.setItem("show-macro-railroad", value);
|
2023-04-09 05:10:16 +00:00
|
|
|
},
|
|
|
|
get keepCratesUpToDate() {
|
|
|
|
return (async () => {
|
|
|
|
let value = await storage.getItem("keep-crates-up-to-date");
|
|
|
|
// Default to false.
|
|
|
|
return value === undefined ? false : value;
|
|
|
|
})();
|
|
|
|
},
|
|
|
|
set keepCratesUpToDate(value) {
|
|
|
|
storage.setItem("keep-crates-up-to-date", value);
|
|
|
|
},
|
2024-05-26 07:33:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default settings;
|