From 144178165c98ec7866d91850205c2967cbceff57 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 12 Feb 2021 12:02:52 -0600 Subject: [PATCH] interface: simplify edit reducer --- pkg/interface/src/logic/reducers/contact-update.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/interface/src/logic/reducers/contact-update.ts b/pkg/interface/src/logic/reducers/contact-update.ts index 44cbc6cfb..932852ece 100644 --- a/pkg/interface/src/logic/reducers/contact-update.ts +++ b/pkg/interface/src/logic/reducers/contact-update.ts @@ -59,18 +59,16 @@ const edit = (json: ContactUpdate, state: S) => { if (!field) { return; } - const contact = state.contacts?.[ship]; + const value = data['edit-field'][field]; - if(!contact) { - return; - } if(field === 'add-group') { - contact.groups.push(value); + state.contacts[ship].groups.push(value); } else if (field === 'remove-group') { - contact.groups = contact.groups.filter(g => g !== value); + state.contacts[ship].groups = + state.contacts[ship].groups.filter(g => g !== value); } else { - contact[field] = value; + state.contacts[ship][field] = value; } } };