diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue
index 3912731..37bc5a0 100644
--- a/src/views/ContactAmountsView.vue
+++ b/src/views/ContactAmountsView.vue
@@ -172,7 +172,9 @@ export default class ContactsView extends Vue {
const account = R.find((acc) => acc.did === activeDid, accounts);
const identity = JSON.parse(account?.identity || "null");
if (!identity) {
- throw new Error("No identity found.");
+ throw new Error(
+ "An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
+ );
}
// load all the time I have given to them
@@ -271,7 +273,9 @@ export default class ContactsView extends Vue {
const account = R.find((acc) => acc.did === this.activeDid, accounts);
const identity = JSON.parse(account?.identity || "null");
if (!identity) {
- throw new Error("No identity found.");
+ throw new Error(
+ "An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
+ );
}
if (identity.keys[0].privateKeyHex !== null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue
index f41ba9c..d7e3142 100644
--- a/src/views/ContactQRScanShowView.vue
+++ b/src/views/ContactQRScanShowView.vue
@@ -64,7 +64,9 @@ export default class ContactQRScanShow extends Vue {
} else {
const identity = JSON.parse(account?.identity || "null");
if (!identity) {
- throw new Error("No identity found.");
+ throw new Error(
+ "An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
+ );
}
const publicKeyHex = identity.keys[0].publicKeyHex;
diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue
index 4aeee80..5200acf 100644
--- a/src/views/ContactsView.vue
+++ b/src/views/ContactsView.vue
@@ -212,8 +212,6 @@ import {
RegisterVerifiableCredential,
SERVICE_ID,
} from "@/libs/endorserServer";
-import AlertMessage from "@/components/AlertMessage";
-import QuickNav from "@/components/QuickNav";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Buffer = require("buffer/").Buffer;
diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue
index dba66d1..27ac498 100644
--- a/src/views/DiscoverView.vue
+++ b/src/views/DiscoverView.vue
@@ -30,6 +30,7 @@
Nearby
@@ -123,7 +124,6 @@ import { Component, Vue } from "vue-facing-decorator";
import { accountsDB, db } from "@/db";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
-import * as R from "ramda";
import { accessToken } from "@/libs/crypto";
import AlertMessage from "@/components/AlertMessage";
import QuickNav from "@/components/QuickNav";
@@ -135,6 +135,8 @@ export default class DiscoverView extends Vue {
activeDid = "";
apiServer = "";
searchTerms = "";
+ alertMessage = "";
+ alertTitle = "";
async mounted() {
await db.open();
@@ -143,53 +145,100 @@ export default class DiscoverView extends Vue {
this.apiServer = settings?.apiServer || "";
}
- public async search() {
+ public async buildHeaders() {
const headers = { "Content-Type": "application/json" };
+
if (this.activeDid) {
await accountsDB.open();
const allAccounts = await accountsDB.accounts.toArray();
- const account = R.find((acc) => acc.did === this.activeDid, allAccounts);
- //console.log("about to parse from", this.activeDid, account?.identity);
+ const account = allAccounts.find((acc) => acc.did === this.activeDid);
const identity = JSON.parse(account?.identity || "null");
+
if (!identity) {
- throw new Error("No identity found.");
+ throw new Error(
+ "An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
+ );
}
- const token = await accessToken(identity);
- headers["Authorization"] = "Bearer " + token;
+
+ headers["Authorization"] = "Bearer " + (await accessToken(identity));
} else {
// it's OK without auth... we just won't get any identifiers
}
+ return headers;
+ }
+
+ public async search() {
const claimContents =
"claimContents=" + encodeURIComponent(this.searchTerms);
const claimType = "claimType=PlanAction";
const queryParams = [claimContents, claimType].join("&");
- return fetch(this.apiServer + "/api/v2/report/claims?" + queryParams, {
- method: "GET",
- headers: headers,
- })
- .then(async (response) => {
- if (response.status !== 200) {
- const details = await response.text();
- throw details;
- }
- return response.json();
- })
- .then((results) => {
- if (results.data) {
- console.log(results.data);
- } else {
- throw JSON.stringify(results);
+
+ try {
+ const response = await fetch(
+ this.apiServer + "/api/v2/report/claims?" + queryParams,
+ {
+ method: "GET",
+ headers: await this.buildHeaders(),
}
- })
- .catch((e) => {
- console.log("Error with feed load:", e);
- this.alertMessage =
- e.userMessage || "There was an error retrieving projects.";
- this.alertTitle = "Error";
- });
+ );
+
+ if (response.status !== 200) {
+ const details = await response.text();
+ throw details;
+ }
+
+ const results = await response.json();
+
+ if (results.data) {
+ console.log("Plans found in that search:", results.data);
+ } else {
+ throw JSON.stringify(results);
+ }
+ } catch (e) {
+ console.log("Error with feed load:", e);
+ this.alertMessage =
+ e.userMessage || "There was an error retrieving projects.";
+ this.alertTitle = "Error";
+ }
}
- alertMessage = "";
- alertTitle = "";
+ public async searchLocal() {
+ const claimContents =
+ "claimContents=" + encodeURIComponent(this.searchTerms);
+ const queryParams = [
+ claimContents,
+ "minLocLat=40.901000",
+ "maxLocLat=40.904000",
+ "westLocLon=-111.914000",
+ "eastLocLon=-111.909000",
+ ].join("&");
+
+ try {
+ const response = await fetch(
+ this.apiServer + "/api/v2/report/plansByLocation?" + queryParams,
+ {
+ method: "GET",
+ headers: await this.buildHeaders(),
+ }
+ );
+
+ if (response.status !== 200) {
+ throw await response.text();
+ }
+
+ const results = await response.json();
+
+ if (results.data) {
+ console.log("Plans found in that location:", results.data);
+ } else {
+ throw JSON.stringify(results);
+ }
+ } catch (e) {
+ console.log("Error with feed load:", e);
+ this.alertMessage =
+ e.userMessage || "There was an error retrieving projects.";
+ this.alertTitle = "Error";
+ }
+ }
}
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 9779ba9..252d6d0 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -70,8 +70,7 @@
diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue
index 01bde83..2354b26 100644
--- a/src/views/ProjectsView.vue
+++ b/src/views/ProjectsView.vue
@@ -204,7 +204,9 @@ export default class ProjectsView extends Vue {
const account = R.find((acc) => acc.did === activeDid, accounts);
const identity = JSON.parse(account?.identity || "null");
if (!identity) {
- throw new Error("No identity found.");
+ throw new Error(
+ "An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
+ );
}
this.current = identity;
this.LoadProjects(identity);