mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-02 07:06:41 +03:00
interface: simplify edit reducer
This commit is contained in:
parent
1c4baea62f
commit
144178165c
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user