fix deletion of labels when deleting contact, only make-all-visible on new contacts
This commit is contained in:
@@ -1593,12 +1593,6 @@ export const PlatformServiceMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove a label from a contact - $deleteContactLabel()
|
||||
* @param did Contact DID
|
||||
* @param label Label string
|
||||
* @returns Promise<boolean> Success status
|
||||
*/
|
||||
async $deleteContactLabel(did: string, label: string): Promise<boolean> {
|
||||
try {
|
||||
await this.$dbExec(
|
||||
@@ -1615,6 +1609,19 @@ export const PlatformServiceMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
async $deleteContactLabelsForDid(did: string): Promise<boolean> {
|
||||
try {
|
||||
await this.$dbExec("DELETE FROM contact_labels WHERE did = ?", [did]);
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`[PlatformServiceMixin] Error deleting labels for contact ${did}:`,
|
||||
error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
async $insertContactLabels(
|
||||
did: string,
|
||||
labels: string[],
|
||||
@@ -2277,6 +2284,7 @@ export interface IPlatformServiceMixin {
|
||||
$getContactIdsWithAllLabels(labels: string[]): Promise<string[]>;
|
||||
$addContactLabel(did: string, label: string): Promise<boolean>;
|
||||
$deleteContactLabel(did: string, label: string): Promise<boolean>;
|
||||
$deleteContactLabelsForDid(did: string): Promise<boolean>;
|
||||
$insertContactLabels(did: string, labels: string[]): Promise<boolean>;
|
||||
$updateContactLabels(did: string, labels: string[]): Promise<boolean>;
|
||||
$getUniqueContactLabels(): Promise<string[]>;
|
||||
@@ -2429,6 +2437,7 @@ declare module "@vue/runtime-core" {
|
||||
$getContactIdsWithAllLabels(labels: string[]): Promise<string[]>;
|
||||
$addContactLabel(did: string, label: string): Promise<boolean>;
|
||||
$deleteContactLabel(did: string, label: string): Promise<boolean>;
|
||||
$deleteContactLabelsForDid(did: string): Promise<boolean>;
|
||||
$insertContactLabels(did: string, labels: string[]): Promise<boolean>;
|
||||
$updateContactLabels(did: string, labels: string[]): Promise<boolean>;
|
||||
$getUniqueContactLabels(): Promise<string[]>;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
class="flex justify-center"
|
||||
>
|
||||
<input v-model="makeVisible" type="checkbox" class="mr-2" />
|
||||
Make my activity visible to these contacts.
|
||||
Make my activity visible to new contacts.
|
||||
</span>
|
||||
|
||||
<div v-if="sameCount > 0">
|
||||
@@ -553,7 +553,8 @@ export default class ContactImportView extends Vue {
|
||||
for (let i = 0; i < this.contactsImporting.length; i++) {
|
||||
if (this.contactsSelected[i]) {
|
||||
const contact = this.contactsImporting[i];
|
||||
if (contact) {
|
||||
const existingContact = this.contactsExisting[contact.did];
|
||||
if (!existingContact) {
|
||||
const visResult = await setVisibilityUtil(
|
||||
this.activeDid,
|
||||
this.apiServer,
|
||||
|
||||
@@ -587,8 +587,14 @@ export default class DIDView extends Vue {
|
||||
*/
|
||||
async deleteContact(contact: Contact) {
|
||||
const success = await this.$deleteContact(contact.did);
|
||||
const successLabels = await this.$deleteContactLabelsForDid(contact.did);
|
||||
if (success) {
|
||||
this.notify.success(NOTIFY_CONTACT_DELETED.message, TIMEOUTS.SHORT);
|
||||
if (!successLabels) {
|
||||
logger.error(
|
||||
`[DIDView] Failed to delete contact labels for ${contact.did}`,
|
||||
);
|
||||
}
|
||||
this.$router.push({ name: "contacts" });
|
||||
} else {
|
||||
this.notify.error(NOTIFY_CONTACT_DELETE_FAILED.message, TIMEOUTS.LONG);
|
||||
|
||||
Reference in New Issue
Block a user