Browse Source

fix error where visibility was set on all imported contacts even if not selected (and specify more types)

master
Trent Larson 2 weeks ago
parent
commit
7db5b9875b
  1. 24
      src/views/ContactImportView.vue

24
src/views/ContactImportView.vue

@ -124,7 +124,10 @@ export default class ContactImportView extends Vue {
contactsSelected: Array<boolean> = []; // whether each contact in contactsImporting is selected contactsSelected: Array<boolean> = []; // whether each contact in contactsImporting is selected
contactDifferences: Record< contactDifferences: Record<
string, string,
Record<string, { new: string; old: string }> Record<
string,
{ new: string | boolean | undefined; old: string | boolean | undefined }
>
> = {}; // for existing contacts, it shows the difference between imported and existing contacts for each key > = {}; // for existing contacts, it shows the difference between imported and existing contacts for each key
importing = false; importing = false;
makeVisible = true; makeVisible = true;
@ -170,12 +173,19 @@ export default class ContactImportView extends Vue {
if (existingContact) { if (existingContact) {
this.contactsExisting[contactIn.did] = existingContact; this.contactsExisting[contactIn.did] = existingContact;
const differences: Record<string, { new: string; old: string }> = {}; const differences: Record<
string,
{
new: string | boolean | undefined;
old: string | boolean | undefined;
}
> = {};
Object.keys(contactIn).forEach((key) => { Object.keys(contactIn).forEach((key) => {
if (contactIn[key] !== existingContact[key]) { // eslint-disable-next-line prettier/prettier
if (contactIn[key as keyof Contact] !== existingContact[key as keyof Contact]) {
differences[key] = { differences[key] = {
old: existingContact[key], old: existingContact[key as keyof Contact],
new: contactIn[key], new: contactIn[key as keyof Contact],
}; };
} }
}); });
@ -211,6 +221,7 @@ export default class ContactImportView extends Vue {
if (this.makeVisible) { if (this.makeVisible) {
const failedVisibileToContacts = []; const failedVisibileToContacts = [];
for (let i = 0; i < this.contactsImporting.length; i++) { for (let i = 0; i < this.contactsImporting.length; i++) {
if (this.contactsSelected[i]) {
const contact = this.contactsImporting[i]; const contact = this.contactsImporting[i];
if (contact) { if (contact) {
const visResult = await setVisibilityUtil( const visResult = await setVisibilityUtil(
@ -226,7 +237,8 @@ export default class ContactImportView extends Vue {
} }
} }
} }
if (failedVisibileToContacts.length) { }
if (failedVisibileToContacts.length > 0) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",

Loading…
Cancel
Save