mirror of
https://github.com/mue/mue.git
synced 2026-07-20 23:44:07 +02:00
refactor: remove unnecessary comments
This commit is contained in:
@@ -18,11 +18,9 @@ const doEvents = (time, message) => {
|
||||
return message;
|
||||
}
|
||||
|
||||
// Get current month & day
|
||||
const month = time.getMonth();
|
||||
const date = time.getDate();
|
||||
|
||||
// Parse the customEvents from localStorage
|
||||
const customEvents = JSON.parse(localStorage.getItem('customEvents') || '[]');
|
||||
|
||||
const event = customEvents.find((e) => e.month - 1 === month && e.date === date);
|
||||
@@ -75,7 +73,6 @@ const Greeting = () => {
|
||||
break;
|
||||
}
|
||||
|
||||
// Events and custom
|
||||
const custom = localStorage.getItem('defaultGreetingMessage');
|
||||
if (custom === 'false') {
|
||||
message = '';
|
||||
@@ -83,7 +80,6 @@ const Greeting = () => {
|
||||
message = doEvents(now, message);
|
||||
}
|
||||
|
||||
// Name
|
||||
let name = '';
|
||||
const data = localStorage.getItem('greetingName');
|
||||
|
||||
@@ -99,7 +95,6 @@ const Greeting = () => {
|
||||
name = name.replace(',', '');
|
||||
}
|
||||
|
||||
// Birthday
|
||||
if (birthday === 'true') {
|
||||
const birth = new Date(localStorage.getItem('birthday'));
|
||||
|
||||
@@ -114,7 +109,6 @@ const Greeting = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the state to the greeting string
|
||||
setGreeting(`${message}${name}`);
|
||||
|
||||
getGreeting();
|
||||
|
||||
@@ -45,53 +45,41 @@ const GreetingOptions = ({ currentSubSection, onSubSectionChange, sectionName })
|
||||
const GREETING_SECTION = 'modals.main.settings.sections.greeting';
|
||||
|
||||
const addEvent = () => {
|
||||
// Retrieve the current array of events from localStorage
|
||||
const customEvents = JSON.parse(localStorage.getItem('customEvents')) || [];
|
||||
|
||||
// Create a new event
|
||||
const newEvent = { id: 'widgets.greeting.halloween', name: '', month: 1, date: 1 };
|
||||
|
||||
// Add the new event to the array
|
||||
const updatedEvents = [...customEvents, newEvent];
|
||||
|
||||
// Add the new event to the array
|
||||
customEvents.push(newEvent);
|
||||
|
||||
// Store the updated array back in localStorage
|
||||
localStorage.setItem('customEvents', JSON.stringify(customEvents));
|
||||
|
||||
setCustomEvents(updatedEvents);
|
||||
};
|
||||
|
||||
const removeEvent = (index) => {
|
||||
// Remove the event at the given index
|
||||
const updatedEvents = customEvents.filter((_, i) => i !== index);
|
||||
|
||||
// Store the updated array back in localStorage
|
||||
localStorage.setItem('customEvents', JSON.stringify(updatedEvents));
|
||||
|
||||
// Update the state
|
||||
setCustomEvents(updatedEvents);
|
||||
};
|
||||
|
||||
const resetEvents = () => {
|
||||
// Reset the events array in localStorage
|
||||
localStorage.setItem('customEvents', JSON.stringify(defaultEvents));
|
||||
|
||||
// Update the state
|
||||
setCustomEvents(defaultEvents);
|
||||
toast(variables.getMessage('toasts.reset'));
|
||||
};
|
||||
|
||||
const updateEvent = (index, updatedEvent) => {
|
||||
// Update the event in your state
|
||||
setCustomEvents((prevEvents) => {
|
||||
const newEvents = [...prevEvents];
|
||||
newEvents[index] = updatedEvent;
|
||||
return newEvents;
|
||||
});
|
||||
|
||||
// Update the event in localStorage
|
||||
const customEvents = JSON.parse(localStorage.getItem('customEvents') || '[]');
|
||||
customEvents[index] = updatedEvent;
|
||||
localStorage.setItem('customEvents', JSON.stringify(customEvents));
|
||||
|
||||
Reference in New Issue
Block a user