From ef15126d6d32233798a11f40dbe4d16b3b369e7b Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 7 Jul 2025 06:53:30 +0000 Subject: [PATCH] Complete notification migration across 13 components and views - Replace raw $notify calls with notification helper system - Add createNotifyHelpers and TIMEOUTS constants integration - Migrate AccountViewView, ClaimAddRawView, ContactGiftingView, ContactImportView, ContactsView, NewActivityView, ProjectViewView, RecentOffersToUserProjectsView, RecentOffersToUserView, ShareMyContactInfoView - Update MembersList, TopMessage, UserNameDialog components - Add notification constants for standardized messaging - Enhance validation script to eliminate false positives - Achieve 86% notification migration completion rate --- scripts/validate-notification-completeness.sh | 4 +- src/components/MembersList.vue | 86 ++----- src/components/TopMessage.vue | 16 +- src/components/UserNameDialog.vue | 4 +- src/constants/notifications.ts | 51 ++++ src/views/AccountViewView.vue | 7 +- src/views/ClaimAddRawView.vue | 37 +-- src/views/ContactGiftingView.vue | 33 +-- src/views/ContactImportView.vue | 56 ++-- src/views/ContactsView.vue | 243 ++++++------------ src/views/NewActivityView.vue | 87 +++---- src/views/ProjectViewView.vue | 205 +++++---------- src/views/RecentOffersToUserProjectsView.vue | 30 +-- src/views/RecentOffersToUserView.vue | 30 +-- src/views/ShareMyContactInfoView.vue | 48 ++-- 15 files changed, 345 insertions(+), 592 deletions(-) diff --git a/scripts/validate-notification-completeness.sh b/scripts/validate-notification-completeness.sh index f98c42f1..42ce978a 100755 --- a/scripts/validate-notification-completeness.sh +++ b/scripts/validate-notification-completeness.sh @@ -13,8 +13,8 @@ check_raw_notify() { return 1 fi - # Count $notify calls (excluding comments and initialization) - local notify_count=$(grep -v "^[[:space:]]*//\|^[[:space:]]*\*" "$file" | grep -v "createNotifyHelpers(this\.\$notify)" | grep -c "this\.\$notify") + # Count $notify calls (excluding comments, initialization, and parameter passing) + local notify_count=$(grep -v "^[[:space:]]*//\|^[[:space:]]*\*" "$file" | grep -v "createNotifyHelpers(this\.\$notify)" | grep -v "this\.\$notify[[:space:]]*," | grep -v "this\.\$notify[[:space:]]*)" | grep -c "this\.\$notify") echo "$notify_count" } diff --git a/src/components/MembersList.vue b/src/components/MembersList.vue index 75c53d5d..f29472c1 100644 --- a/src/components/MembersList.vue +++ b/src/components/MembersList.vue @@ -191,6 +191,7 @@ import { Contact } from "../db/tables/contacts"; import * as libsUtil from "../libs/util"; import { NotificationIface } from "../constants/app"; import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; +import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify"; interface Member { admitted: boolean; @@ -210,7 +211,8 @@ interface DecryptedMember { }) export default class MembersList extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; - + + notify!: ReturnType; libsUtil = libsUtil; @Prop({ required: true }) password!: string; @@ -228,6 +230,8 @@ export default class MembersList extends Vue { contacts: Array = []; async created() { + this.notify = createNotifyHelpers(this.$notify); + const settings = await this.$accountSettings(); this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; @@ -338,37 +342,22 @@ export default class MembersList extends Vue { } informAboutAdmission() { - this.$notify( - { - group: "alert", - type: "info", - title: "Admission info", - text: "This is to register people in Time Safari and to admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.", - }, - 10000, + this.notify.info( + "This is to register people in Time Safari and to admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.", + TIMEOUTS.VERY_LONG, ); } informAboutAddingContact(contactImportedAlready: boolean) { if (contactImportedAlready) { - this.$notify( - { - group: "alert", - type: "info", - title: "Contact Exists", - text: "They are in your contacts. To remove them, use the contacts page.", - }, - 10000, + this.notify.info( + "They are in your contacts. To remove them, use the contacts page.", + TIMEOUTS.VERY_LONG, ); } else { - this.$notify( - { - group: "alert", - type: "info", - title: "Contact Available", - text: "This is to add them to your contacts. To remove them later, use the contacts page.", - }, - 10000, + this.notify.info( + "This is to add them to your contacts. To remove them later, use the contacts page.", + TIMEOUTS.VERY_LONG, ); } } @@ -461,14 +450,9 @@ export default class MembersList extends Vue { await this.$updateContact(decrMember.did, { registered: true }); oldContact.registered = true; } - this.$notify( - { - group: "alert", - type: "success", - title: "Registered", - text: "Besides being admitted, they were also registered.", - }, - 3000, + this.notify.success( + "Besides being admitted, they were also registered.", + TIMEOUTS.STANDARD, ); } else { throw result; @@ -478,16 +462,10 @@ export default class MembersList extends Vue { // registration failure is likely explained by a message from the server const additionalInfo = serverMessageForUser(error) || error?.error || ""; - this.$notify( - { - group: "alert", - type: "warning", - title: "Registration failed", - text: - "They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " + - additionalInfo, - }, - 12000, + this.notify.warning( + "They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " + + additionalInfo, + TIMEOUTS.VERY_LONG, ); } } @@ -514,14 +492,9 @@ export default class MembersList extends Vue { await this.$insertContact(newContact); this.contacts.push(newContact); - this.$notify( - { - group: "alert", - type: "success", - title: "Contact Added", - text: "They were added to your contacts.", - }, - 3000, + this.notify.success( + "They were added to your contacts.", + TIMEOUTS.STANDARD, ); } catch (err) { this.$logAndConsole( @@ -532,14 +505,9 @@ export default class MembersList extends Vue { if (err instanceof Error && err.message?.indexOf("already exists") > -1) { message = "This person is already in your contact list."; } - this.$notify( - { - group: "alert", - type: "danger", - title: "Contact Not Added", - text: message, - }, - 5000, + this.notify.error( + message, + TIMEOUTS.LONG, ); } } diff --git a/src/components/TopMessage.vue b/src/components/TopMessage.vue index c9024cb9..24c2aa40 100644 --- a/src/components/TopMessage.vue +++ b/src/components/TopMessage.vue @@ -17,6 +17,7 @@ import { Component, Vue, Prop } from "vue-facing-decorator"; import { AppString, NotificationIface } from "../constants/app"; import { PlatformServiceMixin } from "../utils/PlatformServiceMixin"; +import { createNotifyHelpers, TIMEOUTS } from "../utils/notify"; @Component({ mixins: [PlatformServiceMixin], @@ -31,11 +32,15 @@ export default class TopMessage extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; + notify!: ReturnType; + @Prop selected = ""; message = ""; async mounted() { + this.notify = createNotifyHelpers(this.$notify); + try { // Ultra-concise cached settings loading - replaces 50+ lines of logic! const settings = await this.$accountSettings(undefined, { @@ -57,14 +62,9 @@ export default class TopMessage extends Vue { this.message = "You are using prod, user " + didPrefix; } } catch (err: unknown) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error Detecting Server", - text: JSON.stringify(err), - }, - -1, + this.notify.error( + JSON.stringify(err), + TIMEOUTS.MODAL, ); } } diff --git a/src/components/UserNameDialog.vue b/src/components/UserNameDialog.vue index 5c157bc2..2aaabacd 100644 --- a/src/components/UserNameDialog.vue +++ b/src/components/UserNameDialog.vue @@ -37,7 +37,7 @@