constantly recheck on home screen if not registered

This commit is contained in:
2024-04-28 17:02:31 -06:00
parent c48b8246f9
commit 8a9bb100ea
3 changed files with 82 additions and 31 deletions

View File

@@ -300,6 +300,7 @@
import { UAParser } from "ua-parser-js";
import { IIdentifier } from "@veramo/core";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import EntityIcon from "@/components/EntityIcon.vue";
import GiftedDialog from "@/components/GiftedDialog.vue";
@@ -323,6 +324,7 @@ import {
contactForDid,
containsNonHiddenDid,
didInfoForContact,
fetchEndorserRateLimits,
getPlanFromCache,
GiverReceiverInputInfo,
GiveSummaryRecord,
@@ -378,7 +380,7 @@ export default class HomeView extends Vue {
showShortcutBvc = false;
userAgentInfo = new UAParser(); // see https://docs.uaparser.js.org/v2/api/ua-parser-js/get-os.html
public async getIdentity(activeDid: string) {
public async getIdentity(activeDid: string): Promise<IIdentifier | null> {
await accountsDB.open();
const account = (await accountsDB.accounts
.where("did")
@@ -424,8 +426,29 @@ export default class HomeView extends Vue {
this.isCreatingIdentifier = false;
}
// this returns a Promise but we don't need to wait for it
// someone may have have registered after sharing contact info
if (!this.isRegistered && this.activeDid) {
const identity = await this.getIdentity(this.activeDid);
try {
const resp = await fetchEndorserRateLimits(
this.apiServer,
this.axios,
identity as IIdentifier,
);
if (resp.status === 200) {
// we just needed to know that they're registered
await db.open();
db.settings.update(MASTER_SETTINGS_KEY, {
isRegistered: true,
});
this.isRegistered = true;
}
} catch (e) {
// ignore the error... just keep us unregistered
}
}
// this returns a Promise but we don't need to wait for it
await this.updateAllFeed();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -713,7 +736,7 @@ export default class HomeView extends Vue {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
displayAmount(code: string, amt: number) {