From e4097f7e4cfe988cde98b4c0f9e75ffe1ab36333 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 25 Jul 2025 21:19:12 +0800 Subject: [PATCH] Fix: properly initialize notify + bulletproofing --- src/views/SearchAreaView.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/views/SearchAreaView.vue b/src/views/SearchAreaView.vue index ad5ac4cd..2f78dd3a 100644 --- a/src/views/SearchAreaView.vue +++ b/src/views/SearchAreaView.vue @@ -173,8 +173,8 @@ export default class SearchAreaView extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; $router!: Router; - // Notification helper system - private notify = createNotifyHelpers(this.$notify); + // Notification helper system - will be initialized in mounted() + private notify: ReturnType | null = null; // User interface state management isChoosingSearchBox = false; @@ -199,6 +199,9 @@ export default class SearchAreaView extends Vue { */ async mounted() { try { + // Initialize notification helper system + this.notify = createNotifyHelpers(this.$notify); + const settings = await this.$accountSettings(); this.searchBox = settings.searchBoxes?.[0] || null; this.resetLatLong(); @@ -321,17 +324,17 @@ export default class SearchAreaView extends Vue { }); // Enhanced notification system with proper timeout - this.notify.success(NOTIFY_SEARCH_AREA_SAVED.text, TIMEOUTS.VERY_LONG); + this.notify?.success(NOTIFY_SEARCH_AREA_SAVED.text, TIMEOUTS.VERY_LONG); this.$router.back(); } catch (err) { logger.error("[SearchAreaView] Failed to store search box", err); // Enhanced notification system with proper timeout - this.notify.error(NOTIFY_SEARCH_AREA_ERROR.text, TIMEOUTS.LONG); + this.notify?.error(NOTIFY_SEARCH_AREA_ERROR.text, TIMEOUTS.LONG); } } else { // Invalid coordinates - show validation warning - this.notify.warning(NOTIFY_SEARCH_AREA_NO_LOCATION.text, TIMEOUTS.LONG); + this.notify?.warning(NOTIFY_SEARCH_AREA_NO_LOCATION.text, TIMEOUTS.LONG); } } @@ -361,12 +364,12 @@ export default class SearchAreaView extends Vue { logger.info("[SearchAreaView] Search box deleted successfully"); // Enhanced notification system with proper timeout - this.notify.success(NOTIFY_SEARCH_AREA_DELETED.text, TIMEOUTS.STANDARD); + this.notify?.success(NOTIFY_SEARCH_AREA_DELETED.text, TIMEOUTS.STANDARD); } catch (err) { logger.error("[SearchAreaView] Failed to delete search box", err); // Enhanced notification system with proper timeout - this.notify.error(NOTIFY_SEARCH_AREA_ERROR.text, TIMEOUTS.LONG); + this.notify?.error(NOTIFY_SEARCH_AREA_ERROR.text, TIMEOUTS.LONG); } }