Browse Source

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.
offer-validation-logic
Matthew Raymer 6 days ago
parent
commit
778d00c2a4
  1. 70
      src/views/HomeView.vue
  2. 8
      src/views/OnboardMeetingListView.vue

70
src/views/HomeView.vue

@ -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

8
src/views/OnboardMeetingListView.vue

@ -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,
);
}

Loading…
Cancel
Save