Considerable cleanup. I think I also found the issue from the other day with values not loading from settings.
This commit is contained in:
@@ -24,7 +24,7 @@ export default class InfiniteScroll extends Vue {
|
||||
};
|
||||
this.observer = new IntersectionObserver(
|
||||
this.handleIntersection,
|
||||
options
|
||||
options,
|
||||
);
|
||||
this.observer.observe(this.$refs.sentinel as HTMLElement);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ function createCamera() {
|
||||
35, // fov = Field Of View
|
||||
1, // aspect ratio (dummy value)
|
||||
0.1, // near clipping plane
|
||||
350 // far clipping plane
|
||||
350, // far clipping plane
|
||||
);
|
||||
|
||||
// move the camera back so we can view the scene
|
||||
|
||||
@@ -62,7 +62,11 @@ export async function loadLandmarks(vue, world, scene, loop) {
|
||||
|
||||
// calculate positions for each claim, especially because some are random
|
||||
const locations = landmarks.map((claim) =>
|
||||
locForGive(claim, world.PLATFORM_SIZE, world.PLATFORM_EDGE_FOR_UNKNOWNS)
|
||||
locForGive(
|
||||
claim,
|
||||
world.PLATFORM_SIZE,
|
||||
world.PLATFORM_EDGE_FOR_UNKNOWNS,
|
||||
),
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
@@ -92,7 +96,7 @@ export async function loadLandmarks(vue, world, scene, loop) {
|
||||
undefined,
|
||||
function (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// calculate when lights shine on appearing claim area
|
||||
@@ -120,7 +124,7 @@ export async function loadLandmarks(vue, world, scene, loop) {
|
||||
.onComplete(() => {
|
||||
scene.remove(light);
|
||||
light.dispose();
|
||||
})
|
||||
}),
|
||||
)
|
||||
.start();
|
||||
world.lights = [...world.lights, light];
|
||||
@@ -129,18 +133,18 @@ export async function loadLandmarks(vue, world, scene, loop) {
|
||||
console.error(
|
||||
"Got bad server response status & data of",
|
||||
resp.status,
|
||||
resp.data
|
||||
resp.data,
|
||||
);
|
||||
vue.setAlert(
|
||||
"Error With Server",
|
||||
"There was an error retrieving your claims from the server."
|
||||
"There was an error retrieving your claims from the server.",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Got exception contacting server:", error);
|
||||
vue.setAlert(
|
||||
"Error With Server",
|
||||
"There was a problem retrieving your claims from the server."
|
||||
"There was a problem retrieving your claims from the server.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export const newIdentifier = (
|
||||
address: string,
|
||||
publicHex: string,
|
||||
privateHex: string,
|
||||
derivationPath: string
|
||||
derivationPath: string,
|
||||
): Omit<IIdentifier, keyof "provider"> => {
|
||||
return {
|
||||
did: DEFAULT_DID_PROVIDER_NAME + ":" + address,
|
||||
@@ -46,7 +46,7 @@ export const newIdentifier = (
|
||||
* @return {*} {[string, string, string, string]}
|
||||
*/
|
||||
export const deriveAddress = (
|
||||
mnemonic: string
|
||||
mnemonic: string,
|
||||
): [string, string, string, string] => {
|
||||
const UPORT_ROOT_DERIVATION_PATH = "m/7696500'/0'/0'/0'";
|
||||
mnemonic = mnemonic.trim().toLowerCase();
|
||||
@@ -134,7 +134,7 @@ export function fromJose(signature: string): {
|
||||
const signatureBytes: Uint8Array = didJwt.base64ToBytes(signature);
|
||||
if (signatureBytes.length < 64 || signatureBytes.length > 65) {
|
||||
throw new TypeError(
|
||||
`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`
|
||||
`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`,
|
||||
);
|
||||
}
|
||||
const r = bytesToHex(signatureBytes.slice(0, 32));
|
||||
|
||||
@@ -85,7 +85,7 @@ export function isHiddenDid(did) {
|
||||
export function didInfo(did, activeDid, identifiers, contacts) {
|
||||
const myId: IIdentifier | undefined = R.find(
|
||||
(i) => i.did === did,
|
||||
identifiers
|
||||
identifiers,
|
||||
);
|
||||
if (myId) {
|
||||
return "You" + (myId.did !== activeDid ? " (Alt ID)" : "");
|
||||
@@ -120,7 +120,7 @@ export async function createAndSubmitGive(
|
||||
toDid: string,
|
||||
description: string,
|
||||
hours: number,
|
||||
fulfillsProjectHandleId?: string
|
||||
fulfillsProjectHandleId?: string,
|
||||
): Promise<AxiosResponse<ClaimResult> | InternalError> {
|
||||
// Make a claim
|
||||
const vcClaim: GiveVerifiableCredential = {
|
||||
|
||||
@@ -81,7 +81,7 @@ function didProviderName(netName: string) {
|
||||
const DEFAULT_DID_PROVIDER_NETWORK_NAME = "mainnet";
|
||||
|
||||
export const DEFAULT_DID_PROVIDER_NAME = didProviderName(
|
||||
DEFAULT_DID_PROVIDER_NETWORK_NAME
|
||||
DEFAULT_DID_PROVIDER_NETWORK_NAME,
|
||||
);
|
||||
|
||||
export const HANDY_APP = false;
|
||||
|
||||
@@ -84,7 +84,7 @@ library.add(
|
||||
faTrashCan,
|
||||
faUser,
|
||||
faUsers,
|
||||
faXmark
|
||||
faXmark,
|
||||
);
|
||||
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
|
||||
@@ -7,7 +7,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
ready() {
|
||||
console.log(
|
||||
"App is being served from cache by a service worker.\n" +
|
||||
"For more details, visit https://goo.gl/AFskqB"
|
||||
"For more details, visit https://goo.gl/AFskqB",
|
||||
);
|
||||
},
|
||||
registered() {
|
||||
@@ -24,7 +24,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
},
|
||||
offline() {
|
||||
console.log(
|
||||
"No internet connection found. App is running in offline mode."
|
||||
"No internet connection found. App is running in offline mode.",
|
||||
);
|
||||
},
|
||||
error(error) {
|
||||
|
||||
@@ -393,7 +393,7 @@ export default class AccountViewView extends Vue {
|
||||
"Clear your cache and start over (after data backup).";
|
||||
console.error(
|
||||
"Telling user to clear cache after contact setting update because:",
|
||||
err
|
||||
err,
|
||||
);
|
||||
this.alertTitle = "Error Updating Contact Setting";
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export default class ContactsView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ export default class ContactsView extends Vue {
|
||||
console.error(
|
||||
"Got bad response status & data of",
|
||||
resp.status,
|
||||
resp.data
|
||||
resp.data,
|
||||
);
|
||||
this.alertTitle = "Error With Server";
|
||||
this.alertMessage =
|
||||
@@ -224,7 +224,7 @@ export default class ContactsView extends Vue {
|
||||
console.error(
|
||||
"Got bad response status & data of",
|
||||
resp2.status,
|
||||
resp2.data
|
||||
resp2.data,
|
||||
);
|
||||
this.alertTitle = "Error With Server";
|
||||
this.alertMessage =
|
||||
@@ -234,7 +234,7 @@ export default class ContactsView extends Vue {
|
||||
const sortedResult: Array<GiveServerRecord> = R.sort(
|
||||
(a, b) =>
|
||||
new Date(b.issuedAt).getTime() - new Date(a.issuedAt).getTime(),
|
||||
result
|
||||
result,
|
||||
);
|
||||
this.giveRecords = sortedResult;
|
||||
} catch (error) {
|
||||
@@ -274,7 +274,7 @@ export default class ContactsView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"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) {
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ export default class ContactsView extends Vue {
|
||||
const allContacts = await db.contacts.toArray();
|
||||
this.contacts = R.sort(
|
||||
(a: Contact, b) => (a.name || "").localeCompare(b.name || ""),
|
||||
allContacts
|
||||
allContacts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ export default class ContactsView extends Vue {
|
||||
|
||||
if (!identity) {
|
||||
console.error(
|
||||
"Attempted to load Give records with no identity available."
|
||||
"Attempted to load Give records with no identity available.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ export default class ContactsView extends Vue {
|
||||
console.error(
|
||||
"Got bad response status & data of",
|
||||
resp.status,
|
||||
resp.data
|
||||
resp.data,
|
||||
);
|
||||
this.alertTitle = "Error With Server";
|
||||
this.alertMessage =
|
||||
@@ -367,7 +367,7 @@ export default class ContactsView extends Vue {
|
||||
console.error(
|
||||
"Got bad response status & data of",
|
||||
resp.status,
|
||||
resp.data
|
||||
resp.data,
|
||||
);
|
||||
this.alertTitle = "Error With Server";
|
||||
this.alertMessage =
|
||||
@@ -402,7 +402,7 @@ export default class ContactsView extends Vue {
|
||||
const allContacts = this.contacts.concat([newContact]);
|
||||
this.contacts = R.sort(
|
||||
(a: Contact, b) => (a.name || "").localeCompare(b.name || ""),
|
||||
allContacts
|
||||
allContacts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ export default class ContactsView extends Vue {
|
||||
this.nameForDid(this.contacts, contact.did) +
|
||||
" with DID " +
|
||||
contact.did +
|
||||
" ?"
|
||||
" ?",
|
||||
)
|
||||
) {
|
||||
await db.open();
|
||||
@@ -427,7 +427,7 @@ export default class ContactsView extends Vue {
|
||||
confirm(
|
||||
"Are you sure you want to use one of your registrations for " +
|
||||
this.nameForDid(this.contacts, contact.did) +
|
||||
"?"
|
||||
"?",
|
||||
)
|
||||
) {
|
||||
await accountsDB.open();
|
||||
@@ -630,7 +630,7 @@ export default class ContactsView extends Vue {
|
||||
"There are " +
|
||||
this.givenToMeUnconfirmed[fromDid] +
|
||||
" unconfirmed hours from them." +
|
||||
" Would you like to confirm some of those hours?"
|
||||
" Would you like to confirm some of those hours?",
|
||||
)
|
||||
) {
|
||||
this.$router.push({
|
||||
@@ -670,7 +670,7 @@ export default class ContactsView extends Vue {
|
||||
" hours " +
|
||||
toFrom +
|
||||
description +
|
||||
"?"
|
||||
"?",
|
||||
)
|
||||
) {
|
||||
this.createAndSubmitGive(
|
||||
@@ -678,7 +678,7 @@ export default class ContactsView extends Vue {
|
||||
fromDid,
|
||||
toDid,
|
||||
parseFloat(this.hourInput),
|
||||
this.hourDescriptionInput
|
||||
this.hourDescriptionInput,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -689,7 +689,7 @@ export default class ContactsView extends Vue {
|
||||
fromDid: string,
|
||||
toDid: string,
|
||||
amount: number,
|
||||
description: string
|
||||
description: string,
|
||||
): Promise<void> {
|
||||
// Make a claim
|
||||
const vcClaim: GiveVerifiableCredential = {
|
||||
|
||||
@@ -156,7 +156,7 @@ export default class DiscoverView extends Vue {
|
||||
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ export default class DiscoverView extends Vue {
|
||||
{
|
||||
method: "GET",
|
||||
headers: await this.buildHeaders(),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (response.status !== 200) {
|
||||
@@ -219,7 +219,7 @@ export default class DiscoverView extends Vue {
|
||||
{
|
||||
method: "GET",
|
||||
headers: await this.buildHeaders(),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (response.status !== 200) {
|
||||
|
||||
@@ -104,6 +104,7 @@ export default class HomeView extends Vue {
|
||||
this.allAccounts = await accountsDB.accounts.toArray();
|
||||
await db.open();
|
||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||
console.log(settings);
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
@@ -128,7 +129,7 @@ export default class HomeView extends Vue {
|
||||
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,9 +140,8 @@ export default class HomeView extends Vue {
|
||||
return headers;
|
||||
}
|
||||
|
||||
updateAllFeed = async () => {
|
||||
public async updateAllFeed() {
|
||||
this.isHiddenSpinner = false;
|
||||
|
||||
await this.retrieveClaims(this.apiServer, null, this.feedPreviousOldestId)
|
||||
.then(async (results) => {
|
||||
if (results.data.length > 0) {
|
||||
@@ -169,16 +169,16 @@ export default class HomeView extends Vue {
|
||||
});
|
||||
|
||||
this.isHiddenSpinner = true;
|
||||
};
|
||||
}
|
||||
|
||||
retrieveClaims = async (endorserApiServer, identifier, beforeId) => {
|
||||
public async retrieveClaims(endorserApiServer, identifier, beforeId) {
|
||||
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId;
|
||||
const response = await fetch(
|
||||
this.apiServer + "/api/v2/report/gives?" + beforeQuery,
|
||||
endorserApiServer + "/api/v2/report/gives?" + beforeQuery,
|
||||
{
|
||||
method: "GET",
|
||||
headers: await buildHeaders(),
|
||||
}
|
||||
headers: await this.buildHeaders(),
|
||||
},
|
||||
);
|
||||
|
||||
if (response.status !== 200) {
|
||||
@@ -192,12 +192,11 @@ export default class HomeView extends Vue {
|
||||
} else {
|
||||
throw JSON.stringify(results);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
giveDescription(giveRecord) {
|
||||
let claim = giveRecord.fullClaim;
|
||||
if (claim.claim) {
|
||||
// it's probably a Verified Credential
|
||||
claim = claim.claim;
|
||||
}
|
||||
|
||||
@@ -208,7 +207,7 @@ export default class HomeView extends Vue {
|
||||
giverDid,
|
||||
this.activeDid,
|
||||
this.allAccounts,
|
||||
this.allContacts
|
||||
this.allContacts,
|
||||
);
|
||||
const gaveAmount = claim.object?.amountOfThisGood
|
||||
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood)
|
||||
@@ -221,7 +220,7 @@ export default class HomeView extends Vue {
|
||||
gaveRecipientId,
|
||||
this.activeDid,
|
||||
this.allAccounts,
|
||||
this.allContacts
|
||||
this.allContacts,
|
||||
)
|
||||
: "";
|
||||
return giverInfo + " gave " + gaveAmount + gaveRecipientInfo;
|
||||
@@ -276,7 +275,7 @@ export default class HomeView extends Vue {
|
||||
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -287,28 +286,41 @@ export default class HomeView extends Vue {
|
||||
giverDid,
|
||||
this.activeDid,
|
||||
description,
|
||||
hours
|
||||
hours,
|
||||
)
|
||||
.then((result) => {
|
||||
const error = result.data?.error;
|
||||
if (result.status !== 201 || error) {
|
||||
if (isGiveCreationError(result)) {
|
||||
const errorMessage = getGiveCreationErrorMessage(result);
|
||||
console.log("Error with give result:", result);
|
||||
this.alertTitle = "Error";
|
||||
this.alertMessage =
|
||||
error?.message || "There was an error recording the give.";
|
||||
errorMessage || "There was an error recording the give.";
|
||||
} else {
|
||||
this.alertTitle = "Success";
|
||||
this.alertMessage = "That gift was recorded.";
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("Error with give caught:", e);
|
||||
.catch((error) => {
|
||||
console.log("Error with give caught:", error);
|
||||
this.alertTitle = "Error";
|
||||
this.alertMessage =
|
||||
e.userMessage ||
|
||||
e.response?.data?.error?.message ||
|
||||
getGiveErrorMessage(error) ||
|
||||
"There was an error recording the give.";
|
||||
});
|
||||
}
|
||||
|
||||
// Helper functions for readability
|
||||
|
||||
isGiveCreationError(result) {
|
||||
return result.status !== 201 || result.data?.error;
|
||||
}
|
||||
|
||||
getGiveCreationErrorMessage(result) {
|
||||
return result.data?.error?.message;
|
||||
}
|
||||
|
||||
getGiveErrorMessage(error) {
|
||||
return error.userMessage || error.response?.data?.error?.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -72,7 +72,7 @@ export default class ImportAccountView extends Vue {
|
||||
this.address,
|
||||
this.publicHex,
|
||||
this.privateHex,
|
||||
this.derivationPath
|
||||
this.derivationPath,
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
@@ -122,7 +122,7 @@ export default class NewEditProjectView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
this.LoadProject(identity);
|
||||
@@ -206,7 +206,7 @@ export default class NewEditProjectView extends Vue {
|
||||
// handleId is new in server v release-1.6.0; remove fullIri when that
|
||||
// version shows up here: https://endorser.ch:3000/api-docs/
|
||||
useAppStore().setProjectId(
|
||||
resp.data.success.handleId || resp.data.success.fullIri
|
||||
resp.data.success.handleId || resp.data.success.fullIri,
|
||||
);
|
||||
setTimeout(
|
||||
function (that: Vue) {
|
||||
@@ -216,7 +216,7 @@ export default class NewEditProjectView extends Vue {
|
||||
that.$router.push(route);
|
||||
},
|
||||
2000,
|
||||
this
|
||||
this,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -235,7 +235,7 @@ export default class NewEditProjectView extends Vue {
|
||||
} else {
|
||||
console.error(
|
||||
"Here's the full error trying to save the claim:",
|
||||
error
|
||||
error,
|
||||
);
|
||||
this.alertTitle = "Claim Error";
|
||||
this.alertMessage = error as string;
|
||||
@@ -259,7 +259,7 @@ export default class NewEditProjectView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
this.SaveProject(identity);
|
||||
|
||||
@@ -250,7 +250,7 @@ export default class ProjectViewView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
this.LoadProject(identity);
|
||||
@@ -299,7 +299,7 @@ export default class ProjectViewView extends Vue {
|
||||
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ export default class ProjectViewView extends Vue {
|
||||
this.activeDid,
|
||||
description,
|
||||
hours,
|
||||
this.projectId
|
||||
this.projectId,
|
||||
);
|
||||
|
||||
if (result.status !== 201 || result.data?.error) {
|
||||
|
||||
@@ -205,7 +205,7 @@ export default class ProjectsView extends Vue {
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service."
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
this.current = identity;
|
||||
|
||||
Reference in New Issue
Block a user