mirror of
https://github.com/mue/mue.git
synced 2026-07-21 07:54:13 +02:00
soon
This commit is contained in:
@@ -11,15 +11,21 @@ export default class Greeting extends React.PureComponent {
|
||||
}
|
||||
|
||||
doEvents(time, message) {
|
||||
if (localStorage.getItem('events') === 'false') return message;
|
||||
if (localStorage.getItem('events') === 'false') {
|
||||
return message;
|
||||
}
|
||||
|
||||
// Get current month & day
|
||||
const m = time.getMonth();
|
||||
const d = time.getDate();
|
||||
|
||||
if (m === 11 && d === 25) message = this.props.language.christmas; // If it's December 25th, set the greeting string to "Merry Christmas"
|
||||
else if (m === 0 && d === 1) message = this.props.language.newyear; // If the date is January 1st, set the greeting string to "Happy new year"
|
||||
else if (m === 9 && d === 31) message = this.props.language.halloween; // If it's October 31st, set the greeting string to "Happy Halloween"
|
||||
if (m === 11 && d === 25) {
|
||||
message = this.props.language.christmas; // If it's December 25th, set the greeting string to "Merry Christmas"
|
||||
} else if (m === 0 && d === 1) {
|
||||
message = this.props.language.newyear; // If the date is January 1st, set the greeting string to "Happy new year"
|
||||
} else if (m === 9 && d === 31) {
|
||||
message = this.props.language.halloween; // If it's October 31st, set the greeting string to "Happy Halloween"
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
@@ -29,13 +35,19 @@ export default class Greeting extends React.PureComponent {
|
||||
const hour = now.getHours();
|
||||
|
||||
let message = this.props.language.evening; // Set the default greeting string to "Good evening"
|
||||
if (hour < 12) message = this.props.language.morning; // If it's before 12am, set the greeting string to "Good morning"
|
||||
else if (hour < 18) message = this.props.language.afternoon; // If it's before 6pm, set the greeting string to "Good afternoon"
|
||||
if (hour < 12) {
|
||||
message = this.props.language.morning; // If it's before 12am, set the greeting string to "Good morning"
|
||||
} else if (hour < 18) {
|
||||
message = this.props.language.afternoon; // If it's before 6pm, set the greeting string to "Good afternoon"
|
||||
}
|
||||
|
||||
// Events
|
||||
message = this.doEvents(now, message);
|
||||
|
||||
const custom = localStorage.getItem('defaultGreetingMessage');
|
||||
if (custom === 'false') message = '';
|
||||
if (custom === 'false') {
|
||||
message = '';
|
||||
}
|
||||
|
||||
// Name
|
||||
let name = '';
|
||||
@@ -45,14 +57,20 @@ export default class Greeting extends React.PureComponent {
|
||||
if (data.replace(/\s/g, '').length > 0) name = `, ${data.trim()}`;
|
||||
}
|
||||
|
||||
if (custom === 'false') name = name.replace(',', '');
|
||||
if (custom === 'false') {
|
||||
name = name.replace(',', '');
|
||||
}
|
||||
|
||||
// Birthday
|
||||
const birth = new Date(localStorage.getItem('birthday'));
|
||||
if (localStorage.getItem('birthdayenabled') === 'true' && birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) message = 'Happy Birthday';
|
||||
if (localStorage.getItem('birthdayenabled') === 'true' && birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) {
|
||||
message = 'Happy Birthday';
|
||||
}
|
||||
|
||||
// Set the state to the greeting string
|
||||
this.setState({ greeting: `${message}${name}` });
|
||||
this.setState({
|
||||
greeting: `${message}${name}`
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
Reference in New Issue
Block a user