forked from jsnbuchanan/crowd-funder-for-time-pwa
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() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
this.activeDid = settings.activeDid || "";
|
||||
|
||||
@@ -308,9 +308,7 @@ import { logger } from "../utils/logger";
|
||||
import { GiveRecordWithContactInfo } from "../interfaces/give";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import {
|
||||
NOTIFY_CONTACT_LOADING_ISSUE,
|
||||
} from "@/constants/notifications";
|
||||
import { NOTIFY_CONTACT_LOADING_ISSUE } from "@/constants/notifications";
|
||||
import * as Package from "../../package.json";
|
||||
|
||||
// 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
|
||||
* Used for displaying contact info in feed and actions
|
||||
@@ -686,36 +648,6 @@ export default class HomeView extends Vue {
|
||||
.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
|
||||
* Triggers updateAllFeed() to populate activity feed
|
||||
|
||||
@@ -150,28 +150,28 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Vue lifecycle hook - component initialization
|
||||
*
|
||||
*
|
||||
* Initializes the component by loading user settings and fetching available
|
||||
* onboarding meetings. This method is called when the component is created
|
||||
* and sets up all necessary data for the meeting list interface.
|
||||
*
|
||||
*
|
||||
* Workflow:
|
||||
* 1. Initialize notification system using createNotifyHelpers
|
||||
* 2. Load user account settings (DID, API server, registration status)
|
||||
* 3. Fetch available onboarding meetings from the server
|
||||
*
|
||||
*
|
||||
* Dependencies:
|
||||
* - PlatformServiceMixin for settings access ($accountSettings)
|
||||
* - Server API for meeting data (fetchMeetings)
|
||||
*
|
||||
*
|
||||
* Error Handling:
|
||||
* - Server errors during meeting fetch are handled in fetchMeetings()
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
async created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
|
||||
// Load user account settings
|
||||
const settings = await this.$accountSettings();
|
||||
|
||||
@@ -185,27 +185,27 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Fetches available onboarding meetings from the server
|
||||
*
|
||||
*
|
||||
* 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,
|
||||
* displays that meeting instead of the full list.
|
||||
*
|
||||
*
|
||||
* Workflow:
|
||||
* 1. Check if user is already attending a meeting (groupOnboardMember endpoint)
|
||||
* 2. If attending: Fetch meeting details and display single meeting view
|
||||
* 3. If not attending: Fetch all available meetings (groupsOnboarding endpoint)
|
||||
* 4. Handle loading states and error conditions
|
||||
*
|
||||
*
|
||||
* API Endpoints Used:
|
||||
* - GET /api/partner/groupOnboardMember - Check current attendance
|
||||
* - GET /api/partner/groupOnboard/{id} - Get meeting details
|
||||
* - GET /api/partner/groupsOnboarding - Get all available meetings
|
||||
*
|
||||
*
|
||||
* State Management:
|
||||
* - Sets isLoading flag during API calls
|
||||
* - Updates attendingMeeting or meetings array
|
||||
* - Handles error states with user notifications
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
async fetchMeetings() {
|
||||
@@ -268,22 +268,22 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Opens the password dialog for joining a meeting
|
||||
*
|
||||
*
|
||||
* This method initiates the process of joining an onboarding meeting by
|
||||
* opening a modal dialog that prompts the user for the meeting password.
|
||||
* The dialog is focused and ready for input when displayed.
|
||||
*
|
||||
*
|
||||
* Workflow:
|
||||
* 1. Clear any previous password input
|
||||
* 2. Store the selected meeting for later use
|
||||
* 3. Show the password dialog modal
|
||||
* 4. Focus the password input field for immediate typing
|
||||
*
|
||||
*
|
||||
* UI State Changes:
|
||||
* - Sets showPasswordDialog to true (shows modal)
|
||||
* - Clears password field for fresh input
|
||||
* - Stores selectedMeeting for password submission
|
||||
*
|
||||
*
|
||||
* @param meeting - The meeting object the user wants to join
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
@@ -301,19 +301,19 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Cancels the password dialog and resets state
|
||||
*
|
||||
*
|
||||
* This method handles the cancellation of the meeting password dialog.
|
||||
* It cleans up the dialog state and resets all related variables to
|
||||
* their initial state, ensuring a clean slate for future dialog interactions.
|
||||
*
|
||||
*
|
||||
* State Cleanup:
|
||||
* - Clears password input field
|
||||
* - Removes selected meeting reference
|
||||
* - Hides password dialog modal
|
||||
*
|
||||
*
|
||||
* This ensures that if the user reopens the dialog, they start with
|
||||
* a fresh state without any leftover data from previous attempts.
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
cancelPasswordDialog() {
|
||||
@@ -324,11 +324,11 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Submits the password and joins the selected 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 to the server to register the user as a meeting participant.
|
||||
*
|
||||
*
|
||||
* Workflow:
|
||||
* 1. Validate that a meeting is selected (safety check)
|
||||
* 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
|
||||
* 5. On success: Navigate to meeting members view with credentials
|
||||
* 6. On failure: Show error notification to user
|
||||
*
|
||||
*
|
||||
* Data Encryption:
|
||||
* - Member data includes: name, DID, registration status
|
||||
* - Data is encrypted using the meeting password for security
|
||||
* - Encrypted data is sent to server for verification
|
||||
*
|
||||
*
|
||||
* Navigation:
|
||||
* - On successful join: Redirects to onboard-meeting-members view
|
||||
* - Passes groupId, password, and memberId as route parameters
|
||||
* - Allows user to see other meeting participants
|
||||
*
|
||||
*
|
||||
* Error Handling:
|
||||
* - Invalid passwords result in server rejection
|
||||
* - Network errors are caught and displayed to user
|
||||
* - All errors are logged for debugging purposes
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
async submitPassword() {
|
||||
@@ -421,33 +421,33 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Prompts user to confirm leaving the current meeting
|
||||
*
|
||||
*
|
||||
* This method initiates the process of leaving an onboarding meeting.
|
||||
* It shows a confirmation dialog to prevent accidental departures,
|
||||
* then handles the server-side removal and UI updates.
|
||||
*
|
||||
*
|
||||
* Workflow:
|
||||
* 1. Display confirmation dialog asking user to confirm departure
|
||||
* 2. On confirmation: Send DELETE request to groupOnboardMember endpoint
|
||||
* 3. On success: Clear attending meeting state and refresh meeting list
|
||||
* 4. Show success notification to user
|
||||
* 5. On failure: Show error notification with details
|
||||
*
|
||||
*
|
||||
* Server Interaction:
|
||||
* - DELETE /api/partner/groupOnboardMember - Removes user from meeting
|
||||
* - Requires authentication headers for user verification
|
||||
* - Server handles the actual removal from meeting database
|
||||
*
|
||||
*
|
||||
* State Management:
|
||||
* - Clears attendingMeeting when successfully left
|
||||
* - Refreshes meetings list to show updated availability
|
||||
* - Updates UI to show meeting list instead of single meeting
|
||||
*
|
||||
*
|
||||
* User Experience:
|
||||
* - Confirmation prevents accidental departures
|
||||
* - Clear feedback on success/failure
|
||||
* - Seamless transition back to meeting list
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
async leaveMeeting() {
|
||||
@@ -464,18 +464,14 @@ export default class OnboardMeetingListView extends Vue {
|
||||
this.attendingMeeting = null;
|
||||
await this.fetchMeetings();
|
||||
|
||||
this.notify.success(
|
||||
"You left the meeting.",
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
this.notify.success("You left the meeting.", TIMEOUTS.LONG);
|
||||
} catch (error) {
|
||||
this.$logAndConsole(
|
||||
"Error leaving meeting: " + errorStringForLog(error),
|
||||
true,
|
||||
);
|
||||
this.notify.error(
|
||||
serverMessageForUser(error) ||
|
||||
"You failed to leave the meeting.",
|
||||
serverMessageForUser(error) || "You failed to leave the meeting.",
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
}
|
||||
@@ -485,22 +481,22 @@ export default class OnboardMeetingListView extends Vue {
|
||||
|
||||
/**
|
||||
* Navigates to the meeting creation page
|
||||
*
|
||||
*
|
||||
* This method handles the navigation to the meeting setup page where
|
||||
* registered users can create new onboarding meetings. It's only
|
||||
* available to users who are registered in the system.
|
||||
*
|
||||
*
|
||||
* Navigation:
|
||||
* - Routes to onboard-meeting-setup view
|
||||
* - Allows user to configure new meeting settings
|
||||
* - Only accessible to registered users (controlled by template)
|
||||
*
|
||||
*
|
||||
* User Flow:
|
||||
* - User clicks "Create Meeting" button
|
||||
* - System navigates to setup page
|
||||
* - User can configure meeting name, password, etc.
|
||||
* - New meeting becomes available to other users
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
createMeeting() {
|
||||
|
||||
Reference in New Issue
Block a user