forked from trent_larson/crowd-funder-for-time-pwa
Complete DIDView.vue triple migration and refactor template handlers
- Fix DIDView.vue notification migration: add missing NOTIFY_SERVER_ACCESS_ERROR and NOTIFY_NO_IDENTITY_ERROR imports - Refactor 5 inline template handlers to proper class methods (goBack, toggleDidDetails, showLargeProfileImage, showLargeIdenticon, hideLargeImage) - Update notification validation script to exclude createNotifyHelpers initialization patterns - DIDView.vue now fully compliant: database migration + SQL abstraction + notification migration complete Improves code organization, testability, and follows Vue.js best practices for template/class separation. All linting passes without errors.
This commit is contained in:
@@ -913,6 +913,47 @@ export const PlatformServiceMixin = {
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Get single contact by DID - $getContact()
|
||||
* Eliminates verbose single contact query patterns
|
||||
* @param did Contact DID to retrieve
|
||||
* @returns Promise<Contact | null> Contact object or null if not found
|
||||
*/
|
||||
async $getContact(did: string): Promise<Contact | null> {
|
||||
const results = await this.$dbQuery(
|
||||
"SELECT * FROM contacts WHERE did = ?",
|
||||
[did],
|
||||
);
|
||||
|
||||
if (!results || !results.values || results.values.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const contactData = this._mapColumnsToValues(
|
||||
results.columns,
|
||||
results.values,
|
||||
);
|
||||
return contactData.length > 0 ? (contactData[0] as Contact) : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete contact by DID - $deleteContact()
|
||||
* Eliminates verbose contact deletion patterns
|
||||
* @param did Contact DID to delete
|
||||
* @returns Promise<boolean> Success status
|
||||
*/
|
||||
async $deleteContact(did: string): Promise<boolean> {
|
||||
try {
|
||||
await this.$dbExec("DELETE FROM contacts WHERE did = ?", [did]);
|
||||
// Invalidate contacts cache
|
||||
this._invalidateCache("contacts_all");
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error("[PlatformServiceMixin] Error deleting contact:", error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generic entity insertion - $insertEntity()
|
||||
* Eliminates verbose INSERT patterns for any entity
|
||||
@@ -1197,6 +1238,8 @@ export interface IPlatformServiceMixin {
|
||||
$insertContact(contact: Partial<Contact>): Promise<boolean>;
|
||||
$updateContact(did: string, changes: Partial<Contact>): Promise<boolean>;
|
||||
$getAllContacts(): Promise<Contact[]>;
|
||||
$getContact(did: string): Promise<Contact | null>;
|
||||
$deleteContact(did: string): Promise<boolean>;
|
||||
$contactCount(): Promise<number>;
|
||||
$insertEntity(
|
||||
tableName: string,
|
||||
@@ -1316,6 +1359,8 @@ declare module "@vue/runtime-core" {
|
||||
$insertContact(contact: Partial<Contact>): Promise<boolean>;
|
||||
$updateContact(did: string, changes: Partial<Contact>): Promise<boolean>;
|
||||
$getAllContacts(): Promise<Contact[]>;
|
||||
$getContact(did: string): Promise<Contact | null>;
|
||||
$deleteContact(did: string): Promise<boolean>;
|
||||
$insertEntity(
|
||||
tableName: string,
|
||||
entity: Record<string, unknown>,
|
||||
|
||||
Reference in New Issue
Block a user