From b139957e3e14f6d06fb34c4368cf8c0ca7d3a344 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 18:44:42 +0800 Subject: [PATCH 01/12] Added identity check --- src/components/World/components/objects/landmarks.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/World/components/objects/landmarks.js b/src/components/World/components/objects/landmarks.js index 3c6dbfaf..a4603376 100644 --- a/src/components/World/components/objects/landmarks.js +++ b/src/components/World/components/objects/landmarks.js @@ -23,6 +23,9 @@ export async function loadLandmarks(vue, world, scene, loop) { const accounts = await accountsDB.accounts.toArray(); const account = R.find((acc) => acc.did === activeDid, accounts); const identity = JSON.parse(account?.identity || "undefined"); + if (!identity) { + throw new Error("No identity found."); + } const token = await accessToken(identity); const url = apiServer + "/api/v2/report/claims?claimType=GiveAction"; From 3f6dbdebef973c54ceb23f335a2747f252db5307 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 18:46:23 +0800 Subject: [PATCH 02/12] Moved checkLimits inside try...catch since it has an identity check --- src/views/AccountViewView.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 17e6e2de..d268dde7 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -420,6 +420,7 @@ export default class AccountViewView extends Vue { db.settings.update(MASTER_SETTINGS_KEY, { activeDid: identity.did, }); + this.checkLimits(); } catch (err) { this.alertMessage = "Clear your cache and start over (after data backup)."; @@ -427,8 +428,6 @@ export default class AccountViewView extends Vue { this.alertTitle = "Error Creating Account"; this.isAlertVisible = true; } - - this.checkLimits(); } public async updateShowContactAmounts() { From 99ea161da01e123da772992c4be8ac931e106c36 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 18:48:01 +0800 Subject: [PATCH 03/12] Removed created() and relocated to mounted() could not replicate issue --- src/views/HomeView.vue | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 3056d921..f9af6e15 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -148,25 +148,17 @@ export default class HomeView extends Vue { // 'created' hook runs when the Vue instance is first created async created() { - await accountsDB.open(); - this.allAccounts = await accountsDB.accounts.toArray(); - await db.open(); - const settings = await db.settings.get(MASTER_SETTINGS_KEY); - this.activeDid = settings?.activeDid || ""; - this.allContacts = await db.contacts.toArray(); - this.feedLastViewedId = settings?.lastViewedClaimId; - } - - // 'mounted' hook runs after initial render - async mounted() { try { + await accountsDB.open(); + this.allAccounts = await accountsDB.accounts.toArray(); await db.open(); const settings = await db.settings.get(MASTER_SETTINGS_KEY); this.apiServer = settings?.apiServer || ""; - + this.activeDid = settings?.activeDid || ""; + this.allContacts = await db.contacts.toArray(); + this.feedLastViewedId = settings?.lastViewedClaimId; this.updateAllFeed(); } catch (err) { - console.log("Error in mounted():", err); this.alertTitle = "Error"; this.alertMessage = err.userMessage || @@ -217,7 +209,6 @@ export default class HomeView extends Vue { (acc) => acc.did === this.activeDid, this.allAccounts ); - //console.log("about to parse from", this.activeDid, account?.identity); const identity = JSON.parse(account?.identity || "null"); if (!identity) { throw new Error("No identity found."); From bcc6de6fc0a3af4be4170c812c232e0451542785 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 19:40:53 +0800 Subject: [PATCH 04/12] New AlertMessage component --- src/components/AlertMessage.vue | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/components/AlertMessage.vue diff --git a/src/components/AlertMessage.vue b/src/components/AlertMessage.vue new file mode 100644 index 00000000..9e8666ef --- /dev/null +++ b/src/components/AlertMessage.vue @@ -0,0 +1,48 @@ + + + + + + From 8d8635a3e6c8051c92e1712277d2e09c0d64cc85 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 19:44:41 +0800 Subject: [PATCH 05/12] Added try...catch and linted --- src/components/AlertMessage.vue | 21 ++++++++++----------- src/views/ContactAmountsView.vue | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/AlertMessage.vue b/src/components/AlertMessage.vue index 9e8666ef..f425e66d 100644 --- a/src/components/AlertMessage.vue +++ b/src/components/AlertMessage.vue @@ -1,14 +1,14 @@ diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index b05099f0..1b1b46fb 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -150,16 +150,23 @@ export default class ContactsView extends Vue { // 'created' hook runs when the Vue instance is first created async created() { - await db.open(); - const contactDid = this.$route.query.contactDid as string; - this.contact = (await db.contacts.get(contactDid)) || null; + try { + await db.open(); + const contactDid = this.$route.query.contactDid as string; + this.contact = (await db.contacts.get(contactDid)) || null; - const settings = await db.settings.get(MASTER_SETTINGS_KEY); - this.activeDid = settings?.activeDid || ""; - this.apiServer = settings?.apiServer || ""; + const settings = await db.settings.get(MASTER_SETTINGS_KEY); + this.activeDid = settings?.activeDid || ""; + this.apiServer = settings?.apiServer || ""; - if (this.activeDid && this.contact) { - this.loadGives(this.activeDid, this.contact); + if (this.activeDid && this.contact) { + this.loadGives(this.activeDid, this.contact); + } + } catch (err) { + this.alertTitle = "Error"; + this.alertMessage = + err.userMessage || + "There was an error retrieving the latest sweet, sweet action."; } } From 3c977a1f281c0a4a3b5705f0368715656d462f43 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 20:24:23 +0800 Subject: [PATCH 06/12] First roll out of an AlertMessage control --- src/components/AlertMessage.vue | 6 ++--- src/views/HomeView.vue | 45 ++++++--------------------------- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/components/AlertMessage.vue b/src/components/AlertMessage.vue index f425e66d..00fee10a 100644 --- a/src/components/AlertMessage.vue +++ b/src/components/AlertMessage.vue @@ -12,12 +12,12 @@ From 0af03227a652f36953a87de7d32bbe07939f4d33 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 21:04:53 +0800 Subject: [PATCH 07/12] Propagated AlertMessage component --- src/views/AccountViewView.vue | 41 +++---------------- src/views/ContactAmountsView.vue | 43 ++++---------------- src/views/ContactQRScanShowView.vue | 37 ++++------------- src/views/ContactsView.vue | 62 ++++------------------------- src/views/DiscoverView.vue | 45 +++++---------------- src/views/NewEditProjectView.vue | 46 ++++----------------- src/views/ProjectViewView.vue | 43 ++++---------------- src/views/SeedBackupView.vue | 41 +++---------------- src/views/StatisticsView.vue | 39 +++--------------- 9 files changed, 65 insertions(+), 332 deletions(-) diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index d268dde7..69569e28 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -307,18 +307,10 @@ - - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
+ @@ -334,6 +326,7 @@ import { db, accountsDB } from "@/db"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { AxiosError } from "axios/index"; +import AlertMessage from "@/components/AlertMessage"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; @@ -347,7 +340,7 @@ interface RateLimits { nextWeekBeginDateTime: string; } -@Component +@Component({ components: { AlertMessage } }) export default class AccountViewView extends Vue { Constants = AppString; @@ -546,27 +539,5 @@ export default class AccountViewView extends Vue { // This same popup code is in many files. alertMessage = ""; alertTitle = ""; - isAlertVisible = false; - public onClickClose() { - this.isAlertVisible = false; - this.alertTitle = ""; - this.alertMessage = ""; - } - public computedAlertClassNames() { - return { - hidden: !this.isAlertVisible, - "dismissable-alert": true, - "bg-slate-100": true, - "p-5": true, - rounded: true, - "drop-shadow-lg": true, - fixed: true, - "top-3": true, - "inset-x-3": true, - "transition-transform": true, - "ease-in": true, - "duration-300": true, - }; - } } diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 1b1b46fb..d086b35b 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -109,25 +109,17 @@ - - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
+ diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index 0cdf6c5e..871dd254 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -64,17 +64,10 @@ :dotsOptions="{ type: 'square' }" class="flex justify-center" /> - - -
- -

{{ alertMessage }}

-
+ @@ -86,6 +79,7 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import * as R from "ramda"; import { SimpleSigner } from "@/libs/crypto"; import * as didJwt from "did-jwt"; +import AlertMessage from "@/components/AlertMessage"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; @@ -93,6 +87,7 @@ const Buffer = require("buffer/").Buffer; @Component({ components: { QRCodeVue3, + AlertMessage, }, }) export default class ContactQRScanShow extends Vue { @@ -144,25 +139,7 @@ export default class ContactQRScanShow extends Vue { } // This same popup code is in many files. + alertTitle = ""; alertMessage = ""; - public onClickClose() { - this.alertMessage = ""; - } - public computedAlertClassNames() { - return { - hidden: !this.alertMessage, - "dismissable-alert": true, - "bg-slate-100": true, - "p-5": true, - rounded: true, - "drop-shadow-lg": true, - fixed: true, - "top-3": true, - "inset-x-3": true, - "transition-transform": true, - "ease-in": true, - "duration-300": true, - }; - } } diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index c2a4143f..0425b802 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -230,19 +230,11 @@ + - - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index cee4e502..06698ce2 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -63,32 +63,25 @@ Cancel + - - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index dc9c5a90..89c54fc7 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -179,18 +179,10 @@ --> - - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
+ @@ -198,7 +190,7 @@ import { AxiosError } from "axios"; import * as moment from "moment"; import * as R from "ramda"; -import { Options, Vue } from "vue-class-component"; +import { Component, Vue } from "vue-facing-decorator"; import GiftedDialog from "@/components/GiftedDialog.vue"; import { accountsDB, db } from "@/db"; @@ -207,9 +199,10 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { createAndSubmitGive } from "@/libs/endorserServer"; import { accessToken } from "@/libs/crypto"; import { IIdentifier } from "@veramo/core"; +import AlertMessage from "@/components/AlertMessage"; -@Options({ - components: { GiftedDialog }, +@Component({ + components: { GiftedDialog, AlertMessage }, }) export default class ProjectViewView extends Vue { activeDid = ""; @@ -379,25 +372,5 @@ export default class ProjectViewView extends Vue { // This same popup code is in many files. alertMessage = ""; alertTitle = ""; - public onClickClose() { - this.alertTitle = ""; - this.alertMessage = ""; - } - public computedAlertClassNames() { - return { - hidden: !this.alertMessage, - "dismissable-alert": true, - "bg-slate-100": true, - "p-5": true, - rounded: true, - "drop-shadow-lg": true, - fixed: true, - "top-3": true, - "inset-x-3": true, - "transition-transform": true, - "ease-in": true, - "duration-300": true, - }; - } } diff --git a/src/views/SeedBackupView.vue b/src/views/SeedBackupView.vue index 9ad683dc..7aa06552 100644 --- a/src/views/SeedBackupView.vue +++ b/src/views/SeedBackupView.vue @@ -85,18 +85,10 @@

{{ activeAccount.mnemonic }}

You do not have an active identity.
- - -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
+ @@ -105,8 +97,9 @@ import { Component, Vue } from "vue-facing-decorator"; import { accountsDB, db } from "@/db"; import * as R from "ramda"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import AlertMessage from "@/components/AlertMessage"; -@Component +@Component({ components: [AlertMessage] }) export default class SeedBackupView extends Vue { activeAccount = null; showSeed = false; @@ -136,27 +129,5 @@ export default class SeedBackupView extends Vue { // This same popup code is in many files. alertMessage = ""; alertTitle = ""; - isAlertVisible = false; - public onClickClose() { - this.isAlertVisible = false; - this.alertTitle = ""; - this.alertMessage = ""; - } - public computedAlertClassNames() { - return { - hidden: !this.isAlertVisible, - "dismissable-alert": true, - "bg-slate-100": true, - "p-5": true, - rounded: true, - "drop-shadow-lg": true, - fixed: true, - "top-3": true, - "inset-x-3": true, - "transition-transform": true, - "ease-in": true, - "duration-300": true, - }; - } } diff --git a/src/views/StatisticsView.vue b/src/views/StatisticsView.vue index 2913b209..af9797ba 100644 --- a/src/views/StatisticsView.vue +++ b/src/views/StatisticsView.vue @@ -79,22 +79,11 @@ {{ worldProperties.animationDurationSeconds }} seconds - - - -
- -
- -

{{ alertTitle }}

-

{{ alertMessage }}

-
+ @@ -102,13 +91,14 @@ import { SVGRenderer } from "three/addons/renderers/SVGRenderer.js"; import { Component, Vue } from "vue-facing-decorator"; import { World } from "@/components/World/World.js"; +import AlertMessage from "@/components/AlertMessage"; interface WorldProperties { startTime?: string; endTime?: string; } -@Component +@Component({ components: { AlertMessage } }) export default class StatisticsView extends Vue { world: World; worldProperties: WorldProperties = {}; @@ -210,23 +200,6 @@ export default class StatisticsView extends Vue { this.alertTitle = ""; this.alertMessage = ""; } - - public computedAlertClassNames() { - return { - hidden: !this.isAlertVisible, - "dismissable-alert": true, - "bg-slate-100": true, - "p-5": true, - rounded: true, - "drop-shadow-lg": true, - fixed: true, - "top-3": true, - "inset-x-3": true, - "transition-transform": true, - "ease-in": true, - "duration-300": true, - }; - } } function ExportToSVG(rendererSVG, filename) { From c31445865e2f6b3038debc123dafd5df347f39a4 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 21:05:45 +0800 Subject: [PATCH 08/12] Straggler --- src/views/SeedBackupView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/SeedBackupView.vue b/src/views/SeedBackupView.vue index 7aa06552..2b40202c 100644 --- a/src/views/SeedBackupView.vue +++ b/src/views/SeedBackupView.vue @@ -99,7 +99,7 @@ import * as R from "ramda"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import AlertMessage from "@/components/AlertMessage"; -@Component({ components: [AlertMessage] }) +@Component({ components: {AlertMessage} }) export default class SeedBackupView extends Vue { activeAccount = null; showSeed = false; From 0fd4b86a8457fd6fe1faf6d1aa2ded5d5c8b6df4 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 21:06:24 +0800 Subject: [PATCH 09/12] A bit of linting --- src/views/SeedBackupView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/SeedBackupView.vue b/src/views/SeedBackupView.vue index 2b40202c..359fea0e 100644 --- a/src/views/SeedBackupView.vue +++ b/src/views/SeedBackupView.vue @@ -99,7 +99,7 @@ import * as R from "ramda"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import AlertMessage from "@/components/AlertMessage"; -@Component({ components: {AlertMessage} }) +@Component({ components: { AlertMessage } }) export default class SeedBackupView extends Vue { activeAccount = null; showSeed = false; From c24022c41cf9450c979250d4fb7216c99cf7f079 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Tue, 4 Jul 2023 19:26:05 +0800 Subject: [PATCH 10/12] Make the visibility of the Alert indirect --- src/components/AlertMessage.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/AlertMessage.vue b/src/components/AlertMessage.vue index 00fee10a..6f3ea5b1 100644 --- a/src/components/AlertMessage.vue +++ b/src/components/AlertMessage.vue @@ -18,15 +18,15 @@ import { Component, Prop, Vue } from "vue-facing-decorator"; export default class AlertMessage extends Vue { @Prop alertTitle = ""; @Prop alertMessage = ""; + isAlertVisible = this.alertMessage; public onClickClose() { - this.alertTitle = ""; - this.alertMessage = ""; + this.isAlertVisible = false; } public computedAlertClassNames() { return { - hidden: !this.alertMessage, + hidden: !this.isAlertVisible, "dismissable-alert": true, "bg-slate-100": true, "p-5": true, From c859778832f663da9d3782f7cc20d224b46afe8f Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Tue, 4 Jul 2023 19:27:57 +0800 Subject: [PATCH 11/12] Add AlertMessage component --- src/views/ProjectsView.vue | 58 +++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index a0dbe958..99596414 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -107,18 +107,22 @@ + diff --git a/src/views/SeedBackupView.vue b/src/views/SeedBackupView.vue index 359fea0e..f896b042 100644 --- a/src/views/SeedBackupView.vue +++ b/src/views/SeedBackupView.vue @@ -103,6 +103,8 @@ import AlertMessage from "@/components/AlertMessage"; export default class SeedBackupView extends Vue { activeAccount = null; showSeed = false; + alertMessage = ""; + alertTitle = ""; // 'created' hook runs when the Vue instance is first created async created() { @@ -118,16 +120,11 @@ export default class SeedBackupView extends Vue { console.error("Got an error loading an identity:", err); this.alertTitle = "Error Loading Account"; this.alertMessage = "Got an error loading your seed data."; - this.isAlertVisible = true; } } showSeedPhrase() { this.showSeed = true; } - - // This same popup code is in many files. - alertMessage = ""; - alertTitle = ""; } diff --git a/src/views/StatisticsView.vue b/src/views/StatisticsView.vue index af9797ba..36684b80 100644 --- a/src/views/StatisticsView.vue +++ b/src/views/StatisticsView.vue @@ -187,19 +187,6 @@ export default class StatisticsView extends Vue { alertTitle = ""; alertMessage = ""; - isAlertVisible = false; - - public setAlert(title, message) { - this.alertTitle = title; - this.alertMessage = message; - this.isAlertVisible = true; - } - - public onClickClose() { - this.isAlertVisible = false; - this.alertTitle = ""; - this.alertMessage = ""; - } } function ExportToSVG(rendererSVG, filename) {