Fix following review

- if we have the brand and that brand value is not what we want it to be... set it
- if we use brandSetting?.value a falsy brandSetting would result in the code below triggering
This commit is contained in:
Richard Cox 2023-07-12 13:12:40 +01:00
parent 3b4fa5176a
commit c16c746fa8
1 changed files with 4 additions and 5 deletions

View File

@ -117,11 +117,9 @@ export default {
return;
}
// The brand setting will only get updated if
// 1) There should be a brand... but there's no brand setting
// 2) There should not be a brand... but there is a brand setting
// The brand setting will only get updated if...
if (neu && !this.brand) {
// 1) There should be a brand... but there's no brand setting
const brandSetting = findBy(this.globalSettings, 'id', SETTING.BRAND);
if (brandSetting) {
@ -140,7 +138,8 @@ export default {
} else if (!neu) {
const brandSetting = findBy(this.globalSettings, 'id', SETTING.BRAND);
if (brandSetting.value !== '') {
if (brandSetting && brandSetting.value !== '') {
// 2) There should not be a brand... but there is a brand setting
brandSetting.value = '';
brandSetting.save();
}