Add notification utility helpers and update PlatformServiceMixin

Created notification utility approaches to consolidate verbose $notify calls:
- Simple function utility (src/utils/notify.ts) - recommended approach
- Vue 3 composable (src/composables/useNotifications.ts)
- Utility class with mixin (src/utils/notificationUtils.ts)

Updated ClaimView.vue to demonstrate usage, reducing notification code by ~70%.
Enhanced PlatformServiceMixin with improved caching and database methods.
Updated ShareMyContactInfoView.vue with mixin improvements.
Provides consistent timeouts, standardized patterns, and type safety.
Ready for migration alongside mixin updates.
This commit is contained in:
Matthew Raymer
2025-07-05 11:37:20 +00:00
parent bbdb962d4d
commit 08c2113504
6 changed files with 683 additions and 188 deletions

View File

@@ -545,8 +545,8 @@ export const PlatformServiceMixin = {
/**
* Load all contacts with caching - $contacts()
* Ultra-concise shortcut with 60s TTL for performance
* @returns Cached mapped array of all contacts
* Contacts are cached for 60 seconds for performance
* @returns Promise<Contact[]> Array of contact objects
*/
async $contacts(): Promise<Contact[]> {
const cacheKey = "contacts_all";
@@ -565,6 +565,16 @@ export const PlatformServiceMixin = {
);
},
/**
* Get total contact count - $contactCount()
* Ultra-concise shortcut for getting number of contacts
* @returns Promise<number> Total number of contacts
*/
async $contactCount(): Promise<number> {
const countRow = await this.$one("SELECT COUNT(*) FROM contacts");
return (countRow?.[0] as number) || 0;
},
/**
* Load settings with optional defaults WITHOUT caching - $settings()
* Settings are loaded fresh every time for immediate consistency
@@ -1136,6 +1146,7 @@ export interface IPlatformServiceMixin {
$insertContact(contact: Partial<Contact>): Promise<boolean>;
$updateContact(did: string, changes: Partial<Contact>): Promise<boolean>;
$getAllContacts(): Promise<Contact[]>;
$contactCount(): Promise<number>;
$insertEntity(
tableName: string,
entity: Record<string, unknown>,
@@ -1211,6 +1222,7 @@ declare module "@vue/runtime-core" {
// Specialized shortcuts - contacts cached, settings fresh
$contacts(): Promise<Contact[]>;
$contactCount(): Promise<number>;
$settings(defaults?: Settings): Promise<Settings>;
$accountSettings(did?: string, defaults?: Settings): Promise<Settings>;