mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-22 07:59:22 +03:00
contacts: process pinned group edits in reducer correctly
This commit is contained in:
parent
6e87e7e1ed
commit
557be6e701
@ -48,11 +48,24 @@ const edit = (json: ContactUpdate, state: S) => {
|
|||||||
data &&
|
data &&
|
||||||
(ship in state.contacts)
|
(ship in state.contacts)
|
||||||
) {
|
) {
|
||||||
const edit = Object.keys(data['edit-field']);
|
console.log(data);
|
||||||
if (edit.length !== 1) {
|
const [field] = Object.keys(data['edit-field']);
|
||||||
|
if (!field) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.contacts[ship][edit[0]] = data['edit-field'][edit[0]];
|
const contact = state.contacts?.[ship];
|
||||||
|
const value = data['edit-field'][field];
|
||||||
|
if(!contact) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(field === 'add-group') {
|
||||||
|
contact.groups.push(value);
|
||||||
|
} else if (field === 'remove-group') {
|
||||||
|
contact.groups = contact.groups.filter(g => g !== value);
|
||||||
|
} else {
|
||||||
|
contact[field] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user