Browse Source

Fix: properly initialize notify + bulletproofing

pull/142/head
Jose Olarte III 2 days ago
parent
commit
e4097f7e4c
  1. 17
      src/views/SearchAreaView.vue

17
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<typeof createNotifyHelpers> | 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);
}
}

Loading…
Cancel
Save