refactor(HomeView): remove unused methods and deduplicate API server calls
- Remove unused loadSettings() method (functionality moved to initializeIdentity) - Remove unused checkRegistrationStatus() method (functionality moved to initializeIdentity) - Deduplicate ensureCorrectApiServer() calls (now only called once in initializeIdentity) - Clean up import statement formatting for NOTIFY_CONTACT_LOADING_ISSUE Reduces code complexity by eliminating 66 lines of dead code while maintaining all existing functionality. Improves maintainability by consolidating initialization logic into a single method.
This commit is contained in:
@@ -285,7 +285,7 @@ export default class ContactQRScanShow extends Vue {
|
|||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
this.notify = createNotifyHelpers(this.$notify);
|
this.notify = createNotifyHelpers(this.$notify);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const settings = await this.$accountSettings();
|
const settings = await this.$accountSettings();
|
||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
|
|||||||
@@ -308,9 +308,7 @@ import { logger } from "../utils/logger";
|
|||||||
import { GiveRecordWithContactInfo } from "../interfaces/give";
|
import { GiveRecordWithContactInfo } from "../interfaces/give";
|
||||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||||
import {
|
import { NOTIFY_CONTACT_LOADING_ISSUE } from "@/constants/notifications";
|
||||||
NOTIFY_CONTACT_LOADING_ISSUE,
|
|
||||||
} from "@/constants/notifications";
|
|
||||||
import * as Package from "../../package.json";
|
import * as Package from "../../package.json";
|
||||||
|
|
||||||
// consolidate this with GiveActionClaim in src/interfaces/claims.ts
|
// consolidate this with GiveActionClaim in src/interfaces/claims.ts
|
||||||
@@ -636,42 +634,6 @@ export default class HomeView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads user settings from database using ultra-concise mixin
|
|
||||||
* Used for displaying settings in feed and actions
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
* Called by mounted() and reloadFeedOnChange()
|
|
||||||
*/
|
|
||||||
private async loadSettings() {
|
|
||||||
// Use the current activeDid (set in initializeIdentity) to get user-specific settings
|
|
||||||
const settings = await this.$accountSettings(this.activeDid, {
|
|
||||||
apiServer: "",
|
|
||||||
activeDid: "",
|
|
||||||
filterFeedByVisible: false,
|
|
||||||
filterFeedByNearby: false,
|
|
||||||
isRegistered: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.apiServer = settings.apiServer || "";
|
|
||||||
|
|
||||||
// **CRITICAL**: Ensure correct API server for platform
|
|
||||||
await this.ensureCorrectApiServer();
|
|
||||||
|
|
||||||
this.activeDid = settings.activeDid || "";
|
|
||||||
this.feedLastViewedClaimId = settings.lastViewedClaimId;
|
|
||||||
this.givenName = settings.firstName || "";
|
|
||||||
this.isFeedFilteredByVisible = !!settings.filterFeedByVisible;
|
|
||||||
this.isFeedFilteredByNearby = !!settings.filterFeedByNearby;
|
|
||||||
this.isRegistered = !!settings.isRegistered;
|
|
||||||
this.lastAckedOfferToUserJwtId = settings.lastAckedOfferToUserJwtId;
|
|
||||||
this.lastAckedOfferToUserProjectsJwtId =
|
|
||||||
settings.lastAckedOfferToUserProjectsJwtId;
|
|
||||||
this.searchBoxes = settings.searchBoxes || [];
|
|
||||||
this.showShortcutBvc = !!settings.showShortcutBvc;
|
|
||||||
this.isAnyFeedFilterOn = checkIsAnyFeedFilterOn(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads user contacts from database using ultra-concise mixin
|
* Loads user contacts from database using ultra-concise mixin
|
||||||
* Used for displaying contact info in feed and actions
|
* Used for displaying contact info in feed and actions
|
||||||
@@ -686,36 +648,6 @@ export default class HomeView extends Vue {
|
|||||||
.map((c) => c.did);
|
.map((c) => c.did);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies user registration status with endorser service
|
|
||||||
* - Checks if unregistered user can access API
|
|
||||||
* - Updates registration status if successful
|
|
||||||
* - Preserves unregistered state on failure
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
* Called by mounted() and initializeIdentity()
|
|
||||||
*/
|
|
||||||
private async checkRegistrationStatus() {
|
|
||||||
if (!this.isRegistered && this.activeDid) {
|
|
||||||
try {
|
|
||||||
const resp = await fetchEndorserRateLimits(
|
|
||||||
this.apiServer,
|
|
||||||
this.axios,
|
|
||||||
this.activeDid,
|
|
||||||
);
|
|
||||||
if (resp.status === 200) {
|
|
||||||
// Ultra-concise settings update with automatic cache invalidation!
|
|
||||||
await this.$saveMySettings({ isRegistered: true });
|
|
||||||
this.isRegistered = true;
|
|
||||||
// Force Vue to re-render the template
|
|
||||||
await this.$nextTick();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// ignore the error... just keep us unregistered
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes feed data
|
* Initializes feed data
|
||||||
* Triggers updateAllFeed() to populate activity feed
|
* Triggers updateAllFeed() to populate activity feed
|
||||||
|
|||||||
@@ -150,28 +150,28 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Vue lifecycle hook - component initialization
|
* Vue lifecycle hook - component initialization
|
||||||
*
|
*
|
||||||
* Initializes the component by loading user settings and fetching available
|
* Initializes the component by loading user settings and fetching available
|
||||||
* onboarding meetings. This method is called when the component is created
|
* onboarding meetings. This method is called when the component is created
|
||||||
* and sets up all necessary data for the meeting list interface.
|
* and sets up all necessary data for the meeting list interface.
|
||||||
*
|
*
|
||||||
* Workflow:
|
* Workflow:
|
||||||
* 1. Initialize notification system using createNotifyHelpers
|
* 1. Initialize notification system using createNotifyHelpers
|
||||||
* 2. Load user account settings (DID, API server, registration status)
|
* 2. Load user account settings (DID, API server, registration status)
|
||||||
* 3. Fetch available onboarding meetings from the server
|
* 3. Fetch available onboarding meetings from the server
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - PlatformServiceMixin for settings access ($accountSettings)
|
* - PlatformServiceMixin for settings access ($accountSettings)
|
||||||
* - Server API for meeting data (fetchMeetings)
|
* - Server API for meeting data (fetchMeetings)
|
||||||
*
|
*
|
||||||
* Error Handling:
|
* Error Handling:
|
||||||
* - Server errors during meeting fetch are handled in fetchMeetings()
|
* - Server errors during meeting fetch are handled in fetchMeetings()
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
async created() {
|
async created() {
|
||||||
this.notify = createNotifyHelpers(this.$notify);
|
this.notify = createNotifyHelpers(this.$notify);
|
||||||
|
|
||||||
// Load user account settings
|
// Load user account settings
|
||||||
const settings = await this.$accountSettings();
|
const settings = await this.$accountSettings();
|
||||||
|
|
||||||
@@ -185,27 +185,27 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches available onboarding meetings from the server
|
* Fetches available onboarding meetings from the server
|
||||||
*
|
*
|
||||||
* This method retrieves the list of onboarding meetings that the user can join.
|
* This method retrieves the list of onboarding meetings that the user can join.
|
||||||
* It first checks if the user is already attending a meeting, and if so,
|
* It first checks if the user is already attending a meeting, and if so,
|
||||||
* displays that meeting instead of the full list.
|
* displays that meeting instead of the full list.
|
||||||
*
|
*
|
||||||
* Workflow:
|
* Workflow:
|
||||||
* 1. Check if user is already attending a meeting (groupOnboardMember endpoint)
|
* 1. Check if user is already attending a meeting (groupOnboardMember endpoint)
|
||||||
* 2. If attending: Fetch meeting details and display single meeting view
|
* 2. If attending: Fetch meeting details and display single meeting view
|
||||||
* 3. If not attending: Fetch all available meetings (groupsOnboarding endpoint)
|
* 3. If not attending: Fetch all available meetings (groupsOnboarding endpoint)
|
||||||
* 4. Handle loading states and error conditions
|
* 4. Handle loading states and error conditions
|
||||||
*
|
*
|
||||||
* API Endpoints Used:
|
* API Endpoints Used:
|
||||||
* - GET /api/partner/groupOnboardMember - Check current attendance
|
* - GET /api/partner/groupOnboardMember - Check current attendance
|
||||||
* - GET /api/partner/groupOnboard/{id} - Get meeting details
|
* - GET /api/partner/groupOnboard/{id} - Get meeting details
|
||||||
* - GET /api/partner/groupsOnboarding - Get all available meetings
|
* - GET /api/partner/groupsOnboarding - Get all available meetings
|
||||||
*
|
*
|
||||||
* State Management:
|
* State Management:
|
||||||
* - Sets isLoading flag during API calls
|
* - Sets isLoading flag during API calls
|
||||||
* - Updates attendingMeeting or meetings array
|
* - Updates attendingMeeting or meetings array
|
||||||
* - Handles error states with user notifications
|
* - Handles error states with user notifications
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
async fetchMeetings() {
|
async fetchMeetings() {
|
||||||
@@ -268,22 +268,22 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the password dialog for joining a meeting
|
* Opens the password dialog for joining a meeting
|
||||||
*
|
*
|
||||||
* This method initiates the process of joining an onboarding meeting by
|
* This method initiates the process of joining an onboarding meeting by
|
||||||
* opening a modal dialog that prompts the user for the meeting password.
|
* opening a modal dialog that prompts the user for the meeting password.
|
||||||
* The dialog is focused and ready for input when displayed.
|
* The dialog is focused and ready for input when displayed.
|
||||||
*
|
*
|
||||||
* Workflow:
|
* Workflow:
|
||||||
* 1. Clear any previous password input
|
* 1. Clear any previous password input
|
||||||
* 2. Store the selected meeting for later use
|
* 2. Store the selected meeting for later use
|
||||||
* 3. Show the password dialog modal
|
* 3. Show the password dialog modal
|
||||||
* 4. Focus the password input field for immediate typing
|
* 4. Focus the password input field for immediate typing
|
||||||
*
|
*
|
||||||
* UI State Changes:
|
* UI State Changes:
|
||||||
* - Sets showPasswordDialog to true (shows modal)
|
* - Sets showPasswordDialog to true (shows modal)
|
||||||
* - Clears password field for fresh input
|
* - Clears password field for fresh input
|
||||||
* - Stores selectedMeeting for password submission
|
* - Stores selectedMeeting for password submission
|
||||||
*
|
*
|
||||||
* @param meeting - The meeting object the user wants to join
|
* @param meeting - The meeting object the user wants to join
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
@@ -301,19 +301,19 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the password dialog and resets state
|
* Cancels the password dialog and resets state
|
||||||
*
|
*
|
||||||
* This method handles the cancellation of the meeting password dialog.
|
* This method handles the cancellation of the meeting password dialog.
|
||||||
* It cleans up the dialog state and resets all related variables to
|
* It cleans up the dialog state and resets all related variables to
|
||||||
* their initial state, ensuring a clean slate for future dialog interactions.
|
* their initial state, ensuring a clean slate for future dialog interactions.
|
||||||
*
|
*
|
||||||
* State Cleanup:
|
* State Cleanup:
|
||||||
* - Clears password input field
|
* - Clears password input field
|
||||||
* - Removes selected meeting reference
|
* - Removes selected meeting reference
|
||||||
* - Hides password dialog modal
|
* - Hides password dialog modal
|
||||||
*
|
*
|
||||||
* This ensures that if the user reopens the dialog, they start with
|
* This ensures that if the user reopens the dialog, they start with
|
||||||
* a fresh state without any leftover data from previous attempts.
|
* a fresh state without any leftover data from previous attempts.
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
cancelPasswordDialog() {
|
cancelPasswordDialog() {
|
||||||
@@ -324,11 +324,11 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits the password and joins the selected meeting
|
* Submits the password and joins the selected meeting
|
||||||
*
|
*
|
||||||
* This method handles the complete workflow of joining an onboarding meeting.
|
* This method handles the complete workflow of joining an onboarding meeting.
|
||||||
* It encrypts the user's member data with the provided password and sends
|
* It encrypts the user's member data with the provided password and sends
|
||||||
* it to the server to register the user as a meeting participant.
|
* it to the server to register the user as a meeting participant.
|
||||||
*
|
*
|
||||||
* Workflow:
|
* Workflow:
|
||||||
* 1. Validate that a meeting is selected (safety check)
|
* 1. Validate that a meeting is selected (safety check)
|
||||||
* 2. Create member data object with user information
|
* 2. Create member data object with user information
|
||||||
@@ -336,22 +336,22 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
* 4. Send encrypted data to server via groupOnboardMember endpoint
|
* 4. Send encrypted data to server via groupOnboardMember endpoint
|
||||||
* 5. On success: Navigate to meeting members view with credentials
|
* 5. On success: Navigate to meeting members view with credentials
|
||||||
* 6. On failure: Show error notification to user
|
* 6. On failure: Show error notification to user
|
||||||
*
|
*
|
||||||
* Data Encryption:
|
* Data Encryption:
|
||||||
* - Member data includes: name, DID, registration status
|
* - Member data includes: name, DID, registration status
|
||||||
* - Data is encrypted using the meeting password for security
|
* - Data is encrypted using the meeting password for security
|
||||||
* - Encrypted data is sent to server for verification
|
* - Encrypted data is sent to server for verification
|
||||||
*
|
*
|
||||||
* Navigation:
|
* Navigation:
|
||||||
* - On successful join: Redirects to onboard-meeting-members view
|
* - On successful join: Redirects to onboard-meeting-members view
|
||||||
* - Passes groupId, password, and memberId as route parameters
|
* - Passes groupId, password, and memberId as route parameters
|
||||||
* - Allows user to see other meeting participants
|
* - Allows user to see other meeting participants
|
||||||
*
|
*
|
||||||
* Error Handling:
|
* Error Handling:
|
||||||
* - Invalid passwords result in server rejection
|
* - Invalid passwords result in server rejection
|
||||||
* - Network errors are caught and displayed to user
|
* - Network errors are caught and displayed to user
|
||||||
* - All errors are logged for debugging purposes
|
* - All errors are logged for debugging purposes
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
async submitPassword() {
|
async submitPassword() {
|
||||||
@@ -421,33 +421,33 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompts user to confirm leaving the current meeting
|
* Prompts user to confirm leaving the current meeting
|
||||||
*
|
*
|
||||||
* This method initiates the process of leaving an onboarding meeting.
|
* This method initiates the process of leaving an onboarding meeting.
|
||||||
* It shows a confirmation dialog to prevent accidental departures,
|
* It shows a confirmation dialog to prevent accidental departures,
|
||||||
* then handles the server-side removal and UI updates.
|
* then handles the server-side removal and UI updates.
|
||||||
*
|
*
|
||||||
* Workflow:
|
* Workflow:
|
||||||
* 1. Display confirmation dialog asking user to confirm departure
|
* 1. Display confirmation dialog asking user to confirm departure
|
||||||
* 2. On confirmation: Send DELETE request to groupOnboardMember endpoint
|
* 2. On confirmation: Send DELETE request to groupOnboardMember endpoint
|
||||||
* 3. On success: Clear attending meeting state and refresh meeting list
|
* 3. On success: Clear attending meeting state and refresh meeting list
|
||||||
* 4. Show success notification to user
|
* 4. Show success notification to user
|
||||||
* 5. On failure: Show error notification with details
|
* 5. On failure: Show error notification with details
|
||||||
*
|
*
|
||||||
* Server Interaction:
|
* Server Interaction:
|
||||||
* - DELETE /api/partner/groupOnboardMember - Removes user from meeting
|
* - DELETE /api/partner/groupOnboardMember - Removes user from meeting
|
||||||
* - Requires authentication headers for user verification
|
* - Requires authentication headers for user verification
|
||||||
* - Server handles the actual removal from meeting database
|
* - Server handles the actual removal from meeting database
|
||||||
*
|
*
|
||||||
* State Management:
|
* State Management:
|
||||||
* - Clears attendingMeeting when successfully left
|
* - Clears attendingMeeting when successfully left
|
||||||
* - Refreshes meetings list to show updated availability
|
* - Refreshes meetings list to show updated availability
|
||||||
* - Updates UI to show meeting list instead of single meeting
|
* - Updates UI to show meeting list instead of single meeting
|
||||||
*
|
*
|
||||||
* User Experience:
|
* User Experience:
|
||||||
* - Confirmation prevents accidental departures
|
* - Confirmation prevents accidental departures
|
||||||
* - Clear feedback on success/failure
|
* - Clear feedback on success/failure
|
||||||
* - Seamless transition back to meeting list
|
* - Seamless transition back to meeting list
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
async leaveMeeting() {
|
async leaveMeeting() {
|
||||||
@@ -464,18 +464,14 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
this.attendingMeeting = null;
|
this.attendingMeeting = null;
|
||||||
await this.fetchMeetings();
|
await this.fetchMeetings();
|
||||||
|
|
||||||
this.notify.success(
|
this.notify.success("You left the meeting.", TIMEOUTS.LONG);
|
||||||
"You left the meeting.",
|
|
||||||
TIMEOUTS.LONG,
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$logAndConsole(
|
this.$logAndConsole(
|
||||||
"Error leaving meeting: " + errorStringForLog(error),
|
"Error leaving meeting: " + errorStringForLog(error),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
this.notify.error(
|
this.notify.error(
|
||||||
serverMessageForUser(error) ||
|
serverMessageForUser(error) || "You failed to leave the meeting.",
|
||||||
"You failed to leave the meeting.",
|
|
||||||
TIMEOUTS.LONG,
|
TIMEOUTS.LONG,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -485,22 +481,22 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates to the meeting creation page
|
* Navigates to the meeting creation page
|
||||||
*
|
*
|
||||||
* This method handles the navigation to the meeting setup page where
|
* This method handles the navigation to the meeting setup page where
|
||||||
* registered users can create new onboarding meetings. It's only
|
* registered users can create new onboarding meetings. It's only
|
||||||
* available to users who are registered in the system.
|
* available to users who are registered in the system.
|
||||||
*
|
*
|
||||||
* Navigation:
|
* Navigation:
|
||||||
* - Routes to onboard-meeting-setup view
|
* - Routes to onboard-meeting-setup view
|
||||||
* - Allows user to configure new meeting settings
|
* - Allows user to configure new meeting settings
|
||||||
* - Only accessible to registered users (controlled by template)
|
* - Only accessible to registered users (controlled by template)
|
||||||
*
|
*
|
||||||
* User Flow:
|
* User Flow:
|
||||||
* - User clicks "Create Meeting" button
|
* - User clicks "Create Meeting" button
|
||||||
* - System navigates to setup page
|
* - System navigates to setup page
|
||||||
* - User can configure meeting name, password, etc.
|
* - User can configure meeting name, password, etc.
|
||||||
* - New meeting becomes available to other users
|
* - New meeting becomes available to other users
|
||||||
*
|
*
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
createMeeting() {
|
createMeeting() {
|
||||||
|
|||||||
Reference in New Issue
Block a user