Browse Source

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

Trent Larson 10 months ago
parent
commit
7db5b9875b
  1. 48
      src/views/ContactImportView.vue

48
src/views/ContactImportView.vue

@ -124,7 +124,10 @@ export default class ContactImportView extends Vue {
contactsSelected: Array<boolean> = []; // whether each contact in contactsImporting is selected
contactDifferences: Record<
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
importing = false;
makeVisible = true;
@ -170,12 +173,19 @@ export default class ContactImportView extends Vue {
if (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) => {
if (contactIn[key] !== existingContact[key]) {
// eslint-disable-next-line prettier/prettier
if (contactIn[key as keyof Contact] !== existingContact[key as keyof Contact]) {
differences[key] = {
old: existingContact[key],
new: contactIn[key],
old: existingContact[key as keyof Contact],
new: contactIn[key as keyof Contact],
};
}
});
@ -211,22 +221,24 @@ export default class ContactImportView extends Vue {
if (this.makeVisible) {
const failedVisibileToContacts = [];
for (let i = 0; i < this.contactsImporting.length; i++) {
const contact = this.contactsImporting[i];
if (contact) {
const visResult = await setVisibilityUtil(
this.activeDid,
this.apiServer,
this.axios,
db,
contact,
true,
);
if (!visResult.success) {
failedVisibileToContacts.push(contact);
if (this.contactsSelected[i]) {
const contact = this.contactsImporting[i];
if (contact) {
const visResult = await setVisibilityUtil(
this.activeDid,
this.apiServer,
this.axios,
db,
contact,
true,
);
if (!visResult.success) {
failedVisibileToContacts.push(contact);
}
}
}
}
if (failedVisibileToContacts.length) {
if (failedVisibileToContacts.length > 0) {
this.$notify(
{
group: "alert",

Loading…
Cancel
Save