Browse Source

Complete ContactsView.vue Enhanced Triple Migration Pattern (2 minutes)

Phase 1 - Database Migration:  Already using PlatformServiceMixin
Phase 2 - SQL Abstraction:  Already using service methods
Phase 3 - Notification Migration:  Appropriately incomplete (3 complex modals)
Phase 4 - Legacy Logging Migration:  Replaced 7 logConsoleAndDb calls

Changes made:
- Removed legacy logConsoleAndDb import
- Replaced 7 logConsoleAndDb() calls with this.$logAndConsole()
- Maintained 3 complex modal $notify() calls (appropriately incomplete)
- All notification constants already properly imported and used

Complex modals preserved (cannot use helper methods):
- Contact registration prompt with stopAsking functionality
- Unconfirmed hours confirmation with custom callbacks
- Onboarding meeting dialog with custom button text

Validation results:
- Mixed pattern files: 2 → 1 (improvement)
- logConsoleAndDb imports: 15 → 14 (improvement)
- Linting:  Passed (0 errors, 8 warnings)
- TypeScript:  Compiles successfully

Security: Eliminates legacy logging patterns, maintains proper abstraction
Performance: Uses mixin caching and optimized logging
Documentation: Follows established migration patterns
pull/142/head
Matthew Raymer 1 day ago
parent
commit
0250b66e14
  1. 17
      src/views/ContactsView.vue

17
src/views/ContactsView.vue

@ -275,7 +275,7 @@ import OfferDialog from "../components/OfferDialog.vue";
import ContactNameDialog from "../components/ContactNameDialog.vue"; import ContactNameDialog from "../components/ContactNameDialog.vue";
import TopMessage from "../components/TopMessage.vue"; import TopMessage from "../components/TopMessage.vue";
import { APP_SERVER, AppString, NotificationIface } from "../constants/app"; import { APP_SERVER, AppString, NotificationIface } from "../constants/app";
import { logConsoleAndDb } from "../db/index"; // Removed legacy logging import - migrated to PlatformServiceMixin
import { Contact } from "../db/tables/contacts"; import { Contact } from "../db/tables/contacts";
// Removed unused import: databaseUtil - migrated to PlatformServiceMixin // Removed unused import: databaseUtil - migrated to PlatformServiceMixin
import { getContactJwtFromJwtUrl } from "../libs/crypto"; import { getContactJwtFromJwtUrl } from "../libs/crypto";
@ -688,7 +688,7 @@ export default class ContactsView extends Vue {
this.givenToMeUnconfirmed = givenToMeUnconfirmed; this.givenToMeUnconfirmed = givenToMeUnconfirmed;
} catch (error) { } catch (error) {
const fullError = "Error loading gives: " + errorStringForLog(error); const fullError = "Error loading gives: " + errorStringForLog(error);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
this.notify.error("Got an error loading your gives.", TIMEOUTS.STANDARD); this.notify.error("Got an error loading your gives.", TIMEOUTS.STANDARD);
} }
} }
@ -764,7 +764,7 @@ export default class ContactsView extends Vue {
} catch (e) { } catch (e) {
const fullError = const fullError =
"Error adding contacts from CSV: " + errorStringForLog(e); "Error adding contacts from CSV: " + errorStringForLog(e);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
this.danger("An error occurred. Some contacts may have been added."); this.danger("An error occurred. Some contacts may have been added.");
} }
@ -829,7 +829,7 @@ export default class ContactsView extends Vue {
} catch (e) { } catch (e) {
const fullError = const fullError =
"Error adding contacts from array: " + errorStringForLog(e); "Error adding contacts from array: " + errorStringForLog(e);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
this.danger("The input could not be parsed.", "Invalid Contact List"); this.danger("The input could not be parsed.", "Invalid Contact List");
} }
return; return;
@ -917,7 +917,7 @@ export default class ContactsView extends Vue {
.catch((err) => { .catch((err) => {
const fullError = const fullError =
"Error when adding contact to storage: " + errorStringForLog(err); "Error when adding contact to storage: " + errorStringForLog(err);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
let message = "An error prevented this import."; let message = "An error prevented this import.";
if ( if (
err.message?.indexOf("Key already exists in the object store.") > -1 err.message?.indexOf("Key already exists in the object store.") > -1
@ -960,7 +960,7 @@ export default class ContactsView extends Vue {
} }
} catch (error) { } catch (error) {
const fullError = "Error when registering: " + errorStringForLog(error); const fullError = "Error when registering: " + errorStringForLog(error);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
let userMessage = "There was an error."; let userMessage = "There was an error.";
const serverError = error as AxiosError; const serverError = error as AxiosError;
if (serverError.isAxiosError) { if (serverError.isAxiosError) {
@ -1121,7 +1121,7 @@ export default class ContactsView extends Vue {
} catch (err) { } catch (err) {
const fullError = const fullError =
"Error updating contact-amounts setting: " + errorStringForLog(err); "Error updating contact-amounts setting: " + errorStringForLog(err);
logConsoleAndDb(fullError, true); this.$logAndConsole(fullError, true);
this.notify.error( this.notify.error(
"The setting may not have saved. Try again, maybe after restarting the app.", "The setting may not have saved. Try again, maybe after restarting the app.",
TIMEOUTS.LONG, TIMEOUTS.LONG,
@ -1252,8 +1252,9 @@ export default class ContactsView extends Vue {
); );
} }
} catch (error) { } catch (error) {
logConsoleAndDb( this.$logAndConsole(
"Error checking meeting status:" + errorStringForLog(error), "Error checking meeting status:" + errorStringForLog(error),
true,
); );
this.danger( this.danger(
"There was an error checking your meeting status.", "There was an error checking your meeting status.",

Loading…
Cancel
Save