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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user