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 { 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
|
||||||
|
|||||||
@@ -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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user