From ddee99cb0b67cc35193137f1c37d2ed80d3b08d6 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Sat, 5 Jul 2025 11:11:32 +0000 Subject: [PATCH] Refactor ClaimView.vue: remove inline template logic, improve types, and centralize logic - Move all complex template logic to computed properties and methods - Replace all `as any` usages with proper TypeScript types (OfferClaim, GiveActionClaim) - Add computed property for claim image, removing inline image access - Route all logging through PlatformServiceMixin - Ensure all icon-only buttons have aria-labels for accessibility - Remove unused imports and direct logger usage - Lint clean: no warnings or errors remain --- src/App.vue | 1 - src/utils/PlatformServiceMixin.ts | 43 ++++++ src/views/ClaimView.vue | 240 +++++++++++++++++++++--------- 3 files changed, 211 insertions(+), 73 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4d7be20c..8f8cb4fc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -345,7 +345,6 @@ interface Settings { }) export default class App extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; - $logAndConsole!: (message: string, isError?: boolean) => Promise; stopAsking = false; diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index cb400209..543314d3 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -1062,6 +1062,39 @@ export const PlatformServiceMixin = { return false; } }, + + // ================================================= + // LOGGING METHODS (convenience methods for components) + // ================================================= + + /** + * Log message to database - $log() + * @param message Message to log + * @param level Log level (info, warn, error) + * @returns Promise + */ + async $log(message: string, level?: string): Promise { + return logger.toDb(message, level); + }, + + /** + * Log error message to database - $logError() + * @param message Error message to log + * @returns Promise + */ + async $logError(message: string): Promise { + return logger.toDb(message, "error"); + }, + + /** + * Log message to console and database - $logAndConsole() + * @param message Message to log + * @param isError Whether this is an error message + * @returns Promise + */ + async $logAndConsole(message: string, isError = false): Promise { + return logger.toConsoleAndDb(message, isError); + }, }, }; @@ -1123,6 +1156,11 @@ export interface IPlatformServiceMixin { did: string, settings: Partial, ): Promise; + + // Logging methods + $log(message: string, level?: string): Promise; + $logError(message: string): Promise; + $logAndConsole(message: string, isError?: boolean): Promise; } // TypeScript declaration merging to eliminate (this as any) type assertions @@ -1217,5 +1255,10 @@ declare module "@vue/runtime-core" { did: string, settings: Partial, ): Promise; + + // Logging methods + $log(message: string, level?: string): Promise; + $logError(message: string): Promise; + $logAndConsole(message: string, isError?: boolean): Promise; } } diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index 2e81e665..b3c56b02 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -8,6 +8,7 @@