rust-search-extension/extension/settings.js

72 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2024-05-26 07:33:35 +00:00
import storage from "./core/storage.js";
// 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() {
return (async () => {
return await storage.getItem('auto-update') || false;
})();
2020-10-26 16:06:00 +00:00
},
set autoUpdate(mode) {
storage.setItem('auto-update', mode);
2020-10-26 16:06:00 +00:00
},
2019-10-31 04:08:04 +00:00
get isOfflineMode() {
return (async () => {
return await storage.getItem('offline-mode') || false;
})();
2019-10-31 04:08:04 +00:00
},
set isOfflineMode(mode) {
storage.setItem('offline-mode', mode);
2019-10-31 04:08:04 +00:00
},
get offlineDocPath() {
return (async () => {
2022-07-05 05:13:03 +00:00
return await storage.getItem('offline-path') || '';
})();
2019-10-31 04:08:04 +00:00
},
set offlineDocPath(path) {
storage.setItem('offline-path', path);
2019-10-31 04:08:04 +00:00
},
2020-05-01 03:46:13 +00:00
get crateRegistry() {
return (async () => {
return await storage.getItem("crate-registry") || "crates.io";
})();
2020-05-01 03:46:13 +00:00
},
set crateRegistry(value) {
storage.setItem("crate-registry", value);
2020-05-01 03:46:13 +00:00
},
get defaultSearch() {
return (async () => {
return await storage.getItem("default-search") || {
thirdPartyDocs: false,
docsRs: true,
attributes: true
};
})();
},
set defaultSearch(value) {
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);
},
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;