mue/src/utils/settings/import.js

19 lines
533 B
JavaScript

import { toast } from 'react-toastify';
import variables from 'config/variables';
/**
* It takes a JSON file of Mue settings, parses it, and then sets the localStorage values to the values in the
* file.
* @param e - The JSON settings string to import
*/
export function importSettings(e) {
const content = JSON.parse(e);
Object.keys(content).forEach((key) => {
localStorage.setItem(key, content[key]);
});
toast(variables.getMessage('toasts.imported'));
variables.stats.postEvent('tab', 'Settings imported');
}