add none option for header greeting

This commit is contained in:
zombieFox 2021-08-18 22:31:51 +01:00
parent 8dbe0e77ea
commit 57d3c4b0c6
3 changed files with 23 additions and 12 deletions

View File

@ -36,6 +36,12 @@ export const Greeting = function({} = {}) {
switch (state.get.current().header.greeting.type) { switch (state.get.current().header.greeting.type) {
case 'none':
value = '';
break;
case 'good': case 'good':
value = this.message[Math.floor(this.now.hours() / 6)]; value = this.message[Math.floor(this.now.hours() / 6)];
@ -57,9 +63,13 @@ export const Greeting = function({} = {}) {
case 'custom': case 'custom':
if (isValidString(state.get.current().header.greeting.custom)) { if (isValidString(state.get.current().header.greeting.custom)) {
value = trimString(state.get.current().header.greeting.custom); value = trimString(state.get.current().header.greeting.custom);
} else { } else {
value = this.message[Math.floor(this.now.hours() / 6)]; value = this.message[Math.floor(this.now.hours() / 6)];
}; };
break; break;
@ -68,14 +78,14 @@ export const Greeting = function({} = {}) {
if (isValidString(state.get.current().header.greeting.name)) { if (isValidString(state.get.current().header.greeting.name)) {
if (state.get.current().header.greeting.type === 'custom') { if (state.get.current().header.greeting.type === 'none') {
if (isValidString(state.get.current().header.greeting.custom)) {
value = value + ', ' + trimString(state.get.current().header.greeting.name) value = value + trimString(state.get.current().header.greeting.name);
} else { } else {
value = value + ', ' + trimString(state.get.current().header.greeting.name)
}; value = value + ', ' + trimString(state.get.current().header.greeting.name);
} else {
value = value + ', ' + trimString(state.get.current().header.greeting.name)
}; };
}; };

View File

@ -129,7 +129,7 @@ header.item.mod = {
} else { } else {
if (state.get.current().header.order.includes(item)) { if (state.get.current().header.order.includes(item)) {
state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1) state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1);
}; };
}; };
@ -166,7 +166,7 @@ header.item.mod = {
} else { } else {
if (state.get.current().header.order.includes(item)) { if (state.get.current().header.order.includes(item)) {
state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1) state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1);
}; };
}; };
@ -186,7 +186,7 @@ header.item.mod = {
} else { } else {
if (state.get.current().header.order.includes(item)) { if (state.get.current().header.order.includes(item)) {
state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1) state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1);
}; };
}; };
@ -222,7 +222,7 @@ header.item.mod = {
} else { } else {
if (state.get.current().header.order.includes(item)) { if (state.get.current().header.order.includes(item)) {
state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1) state.get.current().header.order.splice(state.get.current().header.order.indexOf(item), 1);
}; };
}; };

View File

@ -514,7 +514,8 @@ headerSetting.greeting = (parent) => {
{ id: 'header-greeting-type-good', labelText: '"Good morning..."', value: 'good' }, { id: 'header-greeting-type-good', labelText: '"Good morning..."', value: 'good' },
{ id: 'header-greeting-type-hello', labelText: '"Hello..."', value: 'hello' }, { id: 'header-greeting-type-hello', labelText: '"Hello..."', value: 'hello' },
{ id: 'header-greeting-type-hi', labelText: '"Hi..."', value: 'hi' }, { id: 'header-greeting-type-hi', labelText: '"Hi..."', value: 'hi' },
{ id: 'header-greeting-type-custom', labelText: 'Custom', value: 'custom' } { id: 'header-greeting-type-none', labelText: 'None', description: 'Useful for just displaying your name.', value: 'none' },
{ id: 'header-greeting-type-custom', labelText: 'Custom', description: ['Use your own greeting.', 'Defaults to "Good morning..." if left blank.'], value: 'custom' }
], ],
groupName: 'header-greeting-type', groupName: 'header-greeting-type',
path: 'header.greeting.type', path: 'header.greeting.type',